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
here is the code:
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?
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.
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.
Let me add, for clarity, to SET bit 2 (starting at 0 = LSB):
x |= 4
to CLEAR bit 2:
x &= 4 ^ 0xffff
The idea is to act only on the chosen bit and have no effect on any
other
bits.
I’m trying to change permission on a file on a windows machine.
The documentation of File.chmod says “Actual effects are platform
dependent”. Does Windows support taking away read permissions? How would
you do this in Windows?
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
here is the code:
Windows only supports two modes for File.chmod - 0644 (read/write) or
0444 (readonly).
You can use advanced attribute and security settings with the
win32-file package. However, you cannot make a file unreadable on
Windows except perhaps through ACL.
Regards,
Dan
PS - File.lstat is the same as File.stat on Windows.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.