diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-19 09:19:31 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-19 09:19:31 +0000 |
commit | 22c005569b8cd00ea6895dcc7b621b80d9f15068 (patch) | |
tree | d0e625ef655132a255fbe899d0bf6a361cec8bd5 /file.c | |
parent | 8e877fc51727feed6c07292c3845970103ec109f (diff) | |
download | ruby-22c005569b8cd00ea6895dcc7b621b80d9f15068.tar.gz |
* variable.c (rb_set_class_path): do not set path if
* lib/cgi.rb (CGI::QueryExtension): give extended string, not a
delegater object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 66 |
1 files changed, 56 insertions, 10 deletions
@@ -1046,12 +1046,7 @@ test_wr(obj, fname) if (rb_stat(fname, &st) < 0) return Qnil; if ((st.st_mode & (S_IROTH)) == S_IROTH) { -#ifdef __BORLANDC__ - return UINT2NUM((unsigned short)(st.st_mode & - (S_IRUGO|S_IWUGO|S_IXUGO))); -#else return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); -#endif } #endif return Qnil; @@ -1114,12 +1109,7 @@ test_ww(obj, fname) if (rb_stat(fname, &st) < 0) return Qfalse; if ((st.st_mode & (S_IWOTH)) == S_IWOTH) { -#ifdef __BORLANDC__ - return UINT2NUM((unsigned short)(st.st_mode & - (S_IRUGO|S_IWUGO|S_IXUGO))); -#else return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); -#endif } #endif return Qnil; @@ -3577,6 +3567,33 @@ rb_stat_R(obj) } /* + * call-seq: + * stat.world_readable? => fixnum or nil + * + * If <i>stat</i> is readable by others, returns an integer + * representing the file permission bits of <i>stat</i>. Returns + * <code>nil</code> otherwise. The meaning of the bits is platform + * dependent; on Unix systems, see <code>stat(2)</code>. + * + * m = File.stat("/etc/passwd").world_readable? # => 420 + * sprintf("%o", m) # => "644" + */ + +static VALUE +rb_stat_wr(obj) + VALUE obj; +{ +#ifdef S_IROTH + if ((get_stat(obj)->st_mode & (S_IROTH)) == S_IROTH) { + return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); + } + else { + return Qnil; + } +#endif +} + +/* * call-seq: * stat.writable? -> true or false * @@ -3639,6 +3656,33 @@ rb_stat_W(obj) } /* + * call-seq: + * stat.world_writable? => fixnum or nil + * + * If <i>stat</i> is writable by others, returns an integer + * representing the file permission bits of <i>stat</i>. Returns + * <code>nil</code> otherwise. The meaning of the bits is platform + * dependent; on Unix systems, see <code>stat(2)</code>. + * + * m = File.stat("/tmp").world_writable? # => 511 + * sprintf("%o", m) # => "777" + */ + +static VALUE +rb_stat_ww(obj) + VALUE obj; +{ +#ifdef S_IROTH + if ((get_stat(obj)->st_mode & (S_IWOTH)) == S_IWOTH) { + return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); + } + else { + return Qnil; + } +#endif +} + +/* * call-seq: * stat.executable? => true or false * @@ -4248,8 +4292,10 @@ Init_File() rb_define_method(rb_cStat, "directory?", rb_stat_d, 0); rb_define_method(rb_cStat, "readable?", rb_stat_r, 0); rb_define_method(rb_cStat, "readable_real?", rb_stat_R, 0); + rb_define_method(rb_cStat, "world_readable?", rb_stat_wr, 0); rb_define_method(rb_cStat, "writable?", rb_stat_w, 0); rb_define_method(rb_cStat, "writable_real?", rb_stat_W, 0); + rb_define_method(rb_cStat, "world_writable?", rb_stat_ww, 0); rb_define_method(rb_cStat, "executable?", rb_stat_x, 0); rb_define_method(rb_cStat, "executable_real?", rb_stat_X, 0); rb_define_method(rb_cStat, "file?", rb_stat_f, 0); |