[#2139] Best way to install ri documentation — Dave Thomas <dave@...>

Folks:

69 messages 2004/01/04
[#2140] Re: Best way to install ri documentation — Gavin Sinclair <gsinclair@...> 2004/01/04

On Monday, January 5, 2004, 2:29:57 AM, Dave wrote:

[#2141] Re: Best way to install ri documentation — matz@... (Yukihiro Matsumoto) 2004/01/04

Hi,

[#2145] Re: Best way to install ri documentation — Richard Kilmer <rich@...> 2004/01/05

Perhaps make it available for mirrors and save ruby-lang's bandwidth?

[#2147] Re: Best way to install ri documentation — Dave Thomas <dave@...> 2004/01/05

[#2148] Re: Best way to install ri documentation -- please check this — Dave Thomas <dave@...> 2004/01/05

So, I'm thinking about doing the following? Is this OK with everyone?

[#2149] Re: Best way to install ri documentation -- please check this — "J.Herre" <jlst@...> 2004/01/05

[#2152] Re: Best way to install ri documentation -- please check this — Dave Thomas <dave@...> 2004/01/05

[#2153] Re: Best way to install ri documentation -- please check this — nobu.nokada@... 2004/01/05

Hi,

[#2154] Re: Best way to install ri documentation -- please check this — Dave Thomas <dave@...> 2004/01/05

[#2219] Re: Best way to install ri documentation -- please check this — "James F. Hranicky" <jfh@...> 2004/01/12

On Tue, 6 Jan 2004 00:47:41 +0900

[#2194] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...>

Hello,

27 messages 2004/01/09
[#2195] Re: [PATCH] File.readable_world? and File.writable_world? — Eivind Eklund <eivind@...> 2004/01/09

On Fri, Jan 09, 2004 at 06:02:07PM +0900, Ian Macdonald wrote:

[#2199] Re: [PATCH] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...> 2004/01/09

On Fri 09 Jan 2004 at 23:10:02 +0900, Eivind Eklund wrote:

[#2200] Re: [PATCH] File.readable_world? and File.writable_world? — matz@... (Yukihiro Matsumoto) 2004/01/10

Hi,

[#2203] Re: [PATCH] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...> 2004/01/11

On Sun 11 Jan 2004 at 00:47:33 +0900, Yukihiro Matsumoto wrote:

[#2206] Re: [PATCH] File.readable_world? and File.writable_world? — matz@... (Yukihiro Matsumoto) 2004/01/11

Hi,

[#2208] Re: [PATCH] File.readable_world? and File.writable_world? — Ian Macdonald <ian@...> 2004/01/11

On Sun 11 Jan 2004 at 21:40:22 +0900, Yukihiro Matsumoto wrote:

[#2209] Re: [PATCH] File.readable_world? and File.writable_world? — matz@... (Yukihiro Matsumoto) 2004/01/12

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

12 messages 2004/01/12

Re: [PATCH] File.readable_world? and File.writable_world?

From: Ian Macdonald <ian@...>
Date: 2004-01-13 09:20:08 UTC
List: ruby-core #2256
On Mon 12 Jan 2004 at 10:31:52 +0900, Yukihiro Matsumoto wrote:

> In message "Re: [PATCH] File.readable_world? and File.writable_world?"
>     on 04/01/12, Ian Macdonald <ian@caliban.org> writes:
> 
> |What about Nobu's suggestion to have the methods in File::Stat, too? Do
> |you want me to add them there, also?
> 
> Sounds nice.

OK. Here is the File::Stat patch with associated ChangeLog.

Ian
-- 
Ian Macdonald               | Simulations are like miniskirts, they show 
System Administrator        | a lot and hide the essentials.   -- Hubert 
ian@caliban.org             | Kirrman 
http://www.caliban.org      | 
                            | 

Attachments (2)

ruby-1.8.1-stat.diff (2.66 KB, text/x-diff)
diff -uNr ruby-1.8.1.orig/ruby/file.c ruby-1.8.1/ruby/file.c
--- ruby-1.8.1.orig/ruby/file.c	2004-01-12 20:54:50.000000000 -0800
+++ ruby-1.8.1/ruby/file.c	2004-01-13 00:38:31.000000000 -0800
@@ -3582,6 +3582,38 @@
 }
 
 /*
+ * 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) {
+#ifdef __BORLANDC__
+      return UINT2NUM((unsigned short)(get_stat(obj)->st_mode &
+				       (S_IRUGO|S_IWUGO|S_IXUGO)));
+#else
+      return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
+#endif
+    }
+    else {
+      return Qnil;
+    }
+#endif
+}
+
+/*
  *  call-seq:
  *     stat.writable? -> true or false
  *  
@@ -3644,6 +3676,38 @@
 }
 
 /*
+ * 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) {
+#ifdef __BORLANDC__
+      return UINT2NUM((unsigned short)(get_stat(obj)->st_mode &
+				       (S_IRUGO|S_IWUGO|S_IXUGO)));
+#else
+      return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
+#endif
+    }
+    else {
+      return Qnil;
+    }
+#endif
+}
+
+/*
  *  call-seq:
  *     stat.executable?    => true or false
  *  
@@ -4253,8 +4317,10 @@
     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);
ChangeLog (204 Bytes, text/plain)
Tue Jan 13 01:03:02 PST 2004  Ian Macdonald  <ian@caliban.org>
	
	* file.c (rb_stat_wr, rb_stat_ww): New functions
	  implementing new methods (File::Stat#world_readable?,
	  File::Stat#world_writable?).

In This Thread