Entry
How can I check for read only files?
Aug 7th, 2000 05:12
unknown unknown, Roger Upole, jepler epler
You can use win32file from the win32 extensions.
import win32file
fileatt = win32file.GetFileAttributes(filename)
print fileatt & win32file.FILE_ATTRIBUTE_READONLY
----------
There's an answer already given for using win32 cals.
On unix, you would a construction like
os.stat("file.txt")[ST_MODE] & ST_IWUSR
to check if the file-owner has write permissions.
This flag may not exist on NT, and it's not exactly the same as asking
the question "can I (whoever I am) write this file?).