diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-27 08:45:26 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-27 08:45:26 +0000 |
| commit | 63068eafa8a5085e4a26f6c801276e18ed2476bf (patch) | |
| tree | d0fde81060e1c6b4c5207c7d2fc0d5c50e4f05dd | |
| parent | cdcd5e6a9992cce53123d8feeee3176805262084 (diff) | |
| download | ruby-63068eafa8a5085e4a26f6c801276e18ed2476bf.tar.gz ruby-63068eafa8a5085e4a26f6c801276e18ed2476bf.tar.xz ruby-63068eafa8a5085e4a26f6c801276e18ed2476bf.zip | |
* file.c (file_load_ok): checks if regular file, except for the
platform disallows to open directories, e.g. cygwin.
[ruby-dev:38097], [Bug #1221]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | file.c | 16 |
2 files changed, 15 insertions, 7 deletions
@@ -1,6 +1,8 @@ -Fri Feb 27 15:49:41 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> +Fri Feb 27 17:45:25 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> - * file.c (file_load_ok): checks if regular file. [ruby-dev:38097] + * file.c (file_load_ok): checks if regular file, except for the + platform disallows to open directories, e.g. cygwin. + [ruby-dev:38097], [Bug #1221] Fri Feb 27 14:39:40 2009 NAKAMURA Usaku <usa@ruby-lang.org> @@ -4521,13 +4521,19 @@ rb_path_check(const char *path) static int file_load_ok(const char *path) { - struct stat st; - int ret, fd = open(path, O_RDONLY); + int ret = 1; + int fd = open(path, O_RDONLY); if (fd == -1) return 0; - ret = fstat(fd, &st); +#if !(defined DOSISH || defined __CYGWIN__) + { + struct stat st; + if (fstat(fd, &st) || !S_ISREG(st.st_mode)) { + ret = 0; + } + } +#endif (void)close(fd); - if (ret) return 0; - return S_ISREG(st.st_mode); + return ret; } static int |
