From: Anthony Martinez Date: 2007-06-28T11:43:46+09:00 Subject: Re: File permissions w/Dir.mkdir --vTfKKTivj/mQoluA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 28, 2007 at 11:24:14AM +0900, John Joyce wrote: > In OS X 10.4.9, Ruby 1.8.4 when I use: > Dir.mkdir(file_name, 755) >=20 > The directories created are drop-box, owner-only. > It seems the Dir class expects the leading bit. > So, it should be 0755 and not 755. >=20 > When using: > Dir.mkdir(file_name) >=20 > Without permissions, it appears to default to 0755. >=20 > Just thought this might be useful for some people. > Seems like I read this in the Pickaxe, but I forgot. > It is interesting, since chmod accepts 755 and assumes you mean 0755 > Seems to me that Dir should do the same assuming... but doesn't >=20 Dir.mkdir accepts octal numbers, which is standard notation for this sort of thing. A leading 0 makes Ruby interpret it as octal. You *could* say Dir.mkdir(file_name, 493), but that's sick and twisted.=20 Also, without the second argument it defaults to 0777, which will get modified by the umask. cf lines 912-917 of dir.c in the ruby 1.8.6 source. The reason chmod on the command line accepts 755 is because it can assume you mean octal digits. Also, I think I've come across a few (weirder) chmods that require the leading 0, but that was a long time ago. >=20 > John Joyce >=20 >=20 >=20 --=20 Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot. --vTfKKTivj/mQoluA Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGgyBhKaiGM/xGKzQRAqQlAJ9MAF+KJXlM+n2EtX2PH4QE0WufbACgrH9t k5mUj2YU7TEEunV64eozDKs= =euBT -----END PGP SIGNATURE----- --vTfKKTivj/mQoluA--