[#2139] Best way to install ri documentation — Dave Thomas <dave@...>
Folks:
On Monday, January 5, 2004, 2:29:57 AM, Dave wrote:
Hi,
Perhaps make it available for mirrors and save ruby-lang's bandwidth?
Hi,
So, I'm thinking about doing the following? Is this OK with everyone?
Hi,
On Tue, 6 Jan 2004 00:47:41 +0900
On Mon, 12 Jan 2004 23:30:52 +0900
On Tue, Jan 13, 2004 at 12:01:38AM +0900, Dave Thomas wrote:
Hi, Dave,
Hi,
Hi, daz,
On Tuesday, 6 January 2004 at 15:02:50 +0900, NAKAMURA, Hiroshi wrote:
[#2163] Occasional --enable-pthread hangs... — Nathaniel Talbott <nathaniel@...>
First of all, thanks so much to all those that have helped with
On Jan 5, 2004, at 21:49, Nathaniel Talbott wrote:
[#2186] Absolute paths in shebang lines? — "J.Herre" <jlst@...>
What would the reaction be to reconsidering the following proposal?
[#2194] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...>
Hello,
On Fri, Jan 09, 2004 at 06:02:07PM +0900, Ian Macdonald wrote:
On Fri 09 Jan 2004 at 23:10:02 +0900, Eivind Eklund wrote:
Hi,
On Sun 11 Jan 2004 at 00:47:33 +0900, Yukihiro Matsumoto wrote:
Hi,
On Sun 11 Jan 2004 at 21:40:22 +0900, Yukihiro Matsumoto wrote:
Hi,
On Mon 12 Jan 2004 at 10:31:52 +0900, Yukihiro Matsumoto wrote:
Hi,
On Mon 12 Jan 2004 at 22:36:16 +0900, Yukihiro Matsumoto wrote:
On Mon 12 Jan 2004 at 10:31:52 +0900, Yukihiro Matsumoto wrote:
On Sun 11 Jan 2004 at 00:47:33 +0900, Yukihiro Matsumoto wrote:
[#2211] xxx_init_copy — Dave Thomas <dave@...>
I notivce that there're a bunch of new xxx_init_copy methods: RDoc is
Hi,
Hi,
Hi,
Hi,
[#2216] ruby aborts in data-handling applications — xsdg <xsdg@...>
I reported a similar bug about 2 or 3 months ago. The problem seemed to go
Hi,
I've finally found a combination that will reliably segfault. Since my first post on this topic, I've switched the backend from BDB to GDBM.
Hi,
On Mon, Jan 19, 2004 at 11:32:59AM +0900, nobu.nokada@softhome.net wrote:
[#2225] Fwd: [ruby-cvs] ruby: * file.c (test_wr, test_ww): New functions implementing new — Dave Thomas <dave@...>
On Mon 12 Jan 2004 at 23:38:29 +0900, Dave Thomas wrote:
[#2251] YAML_Unit_Tests failed — "NAKAMURA, Hiroshi" <nahi@...>
Hi,
[#2285] A suggestion for libraries such as base64.rb — Dave Thomas <dave@...>
Some of the older libraries simply insert stuff into the top-level
[#2305] Time#usec round trip problem — Minero Aoki <aamine@...>
Hi,
[#2306] YAML.dump("a".."z") — Minero Aoki <aamine@...>
Hi,
[PATCH] File.readable_world? and File.writable_world?
Hello,
As a system administrator, it's nice to be able to check for world
readable and writable files without having to File.stat the file and
check the mode for the relevant bits. Whilst that's easy enough to do,
the resulting code is too ugly for an elegant language like Ruby, IMHO.
The attached patch implements the File.readable_world? and
File.writable_world? methods. Please consider its inclusion in Ruby. The
diff is against the latest 1.8.1 snapshot.
Thanks,
Ian
--
Ian Macdonald | In this world of sin and sorrow there is
System Administrator | always something to be thankful for; as for
ian@caliban.org | me, I rejoice that I am not a Republican.
http://www.caliban.org | -- H.L. Mencken
|
Attachments (1)
diff -uNr ruby.orig/file.c ruby/file.c
--- ruby.orig/file.c 2003-12-24 07:19:09.000000000 -0800
+++ ruby/file.c 2004-01-09 00:42:36.000000000 -0800
@@ -1015,6 +1015,25 @@
return Qtrue;
}
+/*
+ * call-seq:
+ * File.readable_world?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is readable by anyone.
+ */
+
+static VALUE
+test_rw(obj, fname)
+ VALUE obj, fname;
+{
+#ifdef S_IROTH
+ struct stat st;
+
+ if (rb_stat(fname, &st) < 0) return Qfalse;
+ if (st.st_mode & S_IROTH) return Qtrue;
+#endif
+ return Qfalse;
+}
/*
* call-seq:
@@ -1052,6 +1071,26 @@
/*
* call-seq:
+ * File.writable_world?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is writable by anyone.
+ */
+
+static VALUE
+test_ww(obj, fname)
+ VALUE obj, fname;
+{
+#ifdef S_IWOTH
+ struct stat st;
+
+ if (rb_stat(fname, &st) < 0) return Qfalse;
+ if (st.st_mode & S_IWOTH) return Qtrue;
+#endif
+ return Qfalse;
+}
+
+/*
+ * call-seq:
* File.executable?(file_name) => true or false
*
* Returns <code>true</code> if the named file is executable by the effective
@@ -4052,8 +4091,10 @@
define_filetest_function("exists?", test_e, 1); /* temporary */
define_filetest_function("readable?", test_r, 1);
define_filetest_function("readable_real?", test_R, 1);
+ define_filetest_function("readable_world?", test_rw, 1);
define_filetest_function("writable?", test_w, 1);
define_filetest_function("writable_real?", test_W, 1);
+ define_filetest_function("writable_world?", test_ww, 1);
define_filetest_function("executable?", test_x, 1);
define_filetest_function("executable_real?", test_X, 1);
define_filetest_function("file?", test_f, 1);
diff -uNr ruby.orig/lib/pathname.rb ruby/lib/pathname.rb
--- ruby.orig/lib/pathname.rb 2003-12-25 23:42:35.000000000 -0800
+++ ruby/lib/pathname.rb 2004-01-09 00:19:55.000000000 -0800
@@ -423,6 +423,7 @@
def owned?() FileTest.owned?(@path) end
def readable?() FileTest.readable?(@path) end
def readable_real?() FileTest.readable_real?(@path) end
+ def readable_world?() FileTest.readable_world?(@path) end
def setuid?() FileTest.setuid?(@path) end
def setgid?() FileTest.setgid?(@path) end
def size() FileTest.size(@path) end
@@ -431,6 +432,7 @@
def symlink?() FileTest.symlink?(@path) end
def writable?() FileTest.writable?(@path) end
def writable_real?() FileTest.writable_real?(@path) end
+ def writable_world?() FileTest.writable_world?(@path) end
def zero?() FileTest.zero?(@path) end
end