From: Paul Lutus Date: 2006-11-17T14:20:05+09:00 Subject: Re: Changing permission on a file App Ra wrote: > I'm trying to change permission on a file on a windows machine. This > should work according to the documentation (may be i'm missing something > here). But it doesn't Be specific. What did you expect, and what did you get instead? Any error messages? > here is the code: > > # take away read permission > new_permission = File.lstat("testfile").mode ^ 0004 Hoo-boy. Do you know what "^" actually does? Do it this way: x & 4 ^ 0xffff Meaning original value "AND" the bit-flip of the desired pattern. That way, you actually get a predictable result, regardless of the original value, instead of an unpredictable toggle. > File.chmod(new_permission, "testfile" ) > File.readable?("testfile") #=> true > > or > > new_permission = File.lstat("testfile").mode ^ File::O_R Again, think about what "^" does, and which input arguments produce which output arguments. > File.chmod(new_permission, "testfile" ) > > What am I doing wrong? Also, be sure to say what happened, how you know something is wrong. -- Paul Lutus http://www.arachnoid.com