summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/file.c b/file.c
index ca80795817..3e4db29876 100644
--- a/file.c
+++ b/file.c
@@ -288,7 +288,6 @@ rb_stat_dev_minor(self)
#endif
}
-
/*
* call-seq:
* stat.ino => fixnum
@@ -353,7 +352,6 @@ rb_stat_nlink(self)
return UINT2NUM(get_stat(self)->st_nlink);
}
-
/*
* call-seq:
* stat.uid => fixnum
@@ -388,7 +386,6 @@ rb_stat_gid(self)
return UINT2NUM(get_stat(self)->st_gid);
}
-
/*
* call-seq:
* stat.rdev => fixnum or nil
@@ -518,7 +515,6 @@ rb_stat_blocks(self)
#endif
}
-
/*
* call-seq:
* stat.atime => time
@@ -784,7 +780,6 @@ rb_file_s_lstat(klass, fname)
#endif
}
-
/*
* call-seq:
* file.lstat => stat
@@ -914,7 +909,6 @@ eaccess(path, mode)
*
*/
-
/*
* call-seq:
* File.directory?(file_name) => true or false
@@ -1103,7 +1097,6 @@ test_c(obj, fname)
return Qfalse;
}
-
/*
* call-seq:
* File.exist?(file_name) => true or false
@@ -1156,7 +1149,6 @@ test_R(obj, fname)
return Qtrue;
}
-
/*
* call-seq:
* File.writable?(file_name) => true or false
@@ -1934,7 +1926,6 @@ lchown_internal(path, argp)
rb_sys_fail(path);
}
-
/*
* call-seq:
* file.lchown(owner_int, group_int, file_name,..) => integer
@@ -3630,7 +3621,6 @@ rb_f_test(argc, argv)
}
-
/*
* Document-class: File::Stat
*
@@ -3948,8 +3938,6 @@ rb_stat_r(obj)
return Qtrue;
}
-
-
/*
* call-seq:
* stat.readable_real? -> true or false
@@ -4098,7 +4086,6 @@ rb_stat_x(obj)
* the process.
*/
-
static VALUE
rb_stat_X(obj)
VALUE obj;
@@ -4162,7 +4149,6 @@ rb_stat_z(obj)
return Qfalse;
}
-
/*
* call-seq:
* state.size => integer
@@ -4379,13 +4365,19 @@ 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;
+ int ret = 1;
+ int fd = open(file, O_RDONLY);
+ if (fd == -1) return 0;
+#if !defined DOSISH
+ {
+ struct stat st;
+ if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
+ ret = 0;
+ }
+ }
+#endif
+ (void)close(fd);
+ return ret;
}
extern VALUE rb_load_path;