summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-27 06:49:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-27 06:49:43 +0000
commite23558673dcae92c2395e46fdd583aa6bf50208e (patch)
tree80d0e8460be3c0ae9222427cc214607bc7d84f6f /file.c
parent151527ceca919e8b56af7b729fd89bc317799016 (diff)
* file.c (file_load_ok): checks if regular file. [ruby-dev:38097]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/file.c b/file.c
index 4ca2bda08c..c1b84dd80f 100644
--- a/file.c
+++ b/file.c
@@ -290,7 +290,6 @@ rb_stat_dev_minor(self)
#endif
}
-
/*
* call-seq:
* stat.ino => fixnum
@@ -351,7 +350,6 @@ rb_stat_nlink(self)
return UINT2NUM(get_stat(self)->st_nlink);
}
-
/*
* call-seq:
* stat.uid => fixnum
@@ -386,7 +384,6 @@ rb_stat_gid(self)
return UINT2NUM(get_stat(self)->st_gid);
}
-
/*
* call-seq:
* stat.rdev => fixnum or nil
@@ -516,7 +513,6 @@ rb_stat_blocks(self)
#endif
}
-
/*
* call-seq:
* stat.atime => time
@@ -782,7 +778,6 @@ rb_file_s_lstat(klass, fname)
#endif
}
-
/*
* call-seq:
* file.lstat => stat
@@ -912,7 +907,6 @@ eaccess(path, mode)
*
*/
-
/*
* call-seq:
* File.directory?(file_name) => true or false
@@ -1085,7 +1079,6 @@ test_c(obj, fname)
return Qfalse;
}
-
/*
* call-seq:
* File.exist?(file_name) => true or false
@@ -1138,7 +1131,6 @@ test_R(obj, fname)
return Qtrue;
}
-
/*
* call-seq:
* File.writable?(file_name) => true or false
@@ -1916,7 +1908,6 @@ lchown_internal(path, argp)
rb_sys_fail(path);
}
-
/*
* call-seq:
* file.lchown(owner_int, group_int, file_name,..) => integer
@@ -3624,7 +3615,6 @@ rb_f_test(argc, argv)
}
-
/*
* Document-class: File::Stat
*
@@ -3942,8 +3932,6 @@ rb_stat_r(obj)
return Qtrue;
}
-
-
/*
* call-seq:
* stat.readable_real? -> true or false
@@ -4092,7 +4080,6 @@ rb_stat_x(obj)
* the process.
*/
-
static VALUE
rb_stat_X(obj)
VALUE obj;
@@ -4156,7 +4143,6 @@ rb_stat_z(obj)
return Qfalse;
}
-
/*
* call-seq:
* state.size => integer
@@ -4373,13 +4359,13 @@ static int
file_load_ok(file)
const char *file;
{
- FILE *f;
-
- if (!file) return 0;
- f = fopen(file, "r");
- if (f == NULL) return 0;
- fclose(f);
- return 1;
+ struct stat st;
+ int ret, fd = open(file, O_RDONLY);
+ if (fd == -1) return 0;
+ ret = fstat(fd, &st);
+ (void)close(fd);
+ if (ret) return 0;
+ return S_ISREG(st.st_mode);
}
static int