From: Yohanes Santoso Date: 2002-06-17T08:57:49+09:00 Subject: Re: File.new('foo', 0600 , 'wb') Tobias Reif writes: > Carlos wrote: > > > > So you cannot specify permissions if you use "wb", this parameter is > > ignored. If you want to specify permissions, you must use numeric mode. Guy > > is suggesting that you do: > > flag = File::CREAT > > flag |= File::BINARY if File::Constants.const_defined?("BINARY") > > File.new "foo", flag, 0600 > > > I'm not sure if an alternative would be feasible, but I find all this > very quirky. I just want save some image data, with permission 0600; > the code should be very short and simple, and work on all major > OSes. I do not want to write three lines of uppercase double colon > mess. Well, you have two conflicting requirements: permission 0600 and platform independence. Permission 0600 may produce unexepected permission/result in Windows or other non-POSIX OSes, depending on the reliability and conformance of the Unix emulation layer on those OSes, and File::BINARY is invalid in UNIX. The code above is as succinct as it can be if you want it to operate in both Unix and Windows. YS.