Changing permission on a file

A

App Ra

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:

# take away read permission
new_permission = File.lstat("testfile").mode ^ 0004
File.chmod(new_permission, "testfile" )
File.readable?("testfile") #=> true

or

new_permission = File.lstat("testfile").mode ^ File::O_R
File.chmod(new_permission, "testfile" )

What am I doing wrong?

Thanks
Apparna
 
P

Pit Capitain

App said:
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?

Regards,
Pit
 
D

Daniel Berger

App said:
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:

# take away read permission
new_permission = File.lstat("testfile").mode ^ 0004
File.chmod(new_permission, "testfile" )
File.readable?("testfile") #=> true

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,219
Messages
2,571,117
Members
47,729
Latest member
taulaju99

Latest Threads

Top