File and directory permissions in windows

I

ismael

Hi all

I have some problems to get the the permissions on windows. I use a simple
code that run perfectly in UNIX but give me wrong information on Windows. I
found this code searching by google:

import os
import stat

print os.stat('fichero.txt')
st = os.stat('fichero.txt')

mode = st[stat.ST_MODE]
print mode
if mode & stat.S_IREAD: # same as stat.S_IRUSR
print "readable"
if mode & stat.S_IWRITE: # same as stat.S_IWUSR
print "writable"
if mode & stat.S_IEXEC: # same as stat.S_IXUSR
print "executable"

This code allways say that file is readable and writable except if is a read
only file.
Looking for a solution I found this code that use other library but the
result is the same:

import nt
import os
import sys

if (sys.platform == "win32"):
print nt.access ('c:/prueba/fichero.txt', nt.W_OK)

is there a solution for this?, another library or code? Anything that i do
wrong?
Thanks everybody.
Best regards.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top