* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@22658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c660a9c466
commit
12331d4939
@ -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>
|
Fri Feb 27 14:39:40 2009 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
16
file.c
16
file.c
@ -4521,13 +4521,19 @@ rb_path_check(const char *path)
|
|||||||
static int
|
static int
|
||||||
file_load_ok(const char *path)
|
file_load_ok(const char *path)
|
||||||
{
|
{
|
||||||
struct stat st;
|
int ret = 1;
|
||||||
int ret, fd = open(path, O_RDONLY);
|
int fd = open(path, O_RDONLY);
|
||||||
if (fd == -1) return 0;
|
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);
|
(void)close(fd);
|
||||||
if (ret) return 0;
|
return ret;
|
||||||
return S_ISREG(st.st_mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user