How can I check 4 readonly?

jepler epler jepler.lnk at lnk.ispi.net
Thu Aug 3 19:50:54 EDT 2000


On Thu, 3 Aug 2000 19:56:18 +0200, Franz GEIGER
 <fgeiger at datec.at> wrote:
>I am desperatly trying to retrieve something like a readonly flag on files.
>os.stat("file.txt")[ST_MODE] returns the value of st_mode, but there is no
>S_-function like S_ISDIR() to check for a readonly flag. O_RDONLY is only
>for opening() files (its value is 0). Any idea?
>
>Platform: Python 1.5.2 on NT4.
>
>Many thanks in advance and best regards
>Franz GEIGER

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?).

Jeff



More information about the Python-list mailing list