Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5783

Re: os.access giving incorrect results on Windows

Date 2011-05-19 20:43 +0100
From Tim Golden <mail@timgolden.me.uk>
Subject Re: os.access giving incorrect results on Windows
References <21581D39FA3BDF40904D75AF9653CE2606567E4A@blrex.prog.altair.com>
Newsgroups comp.lang.python
Message-ID <mailman.1798.1305834251.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 19/05/2011 20:37, Ayaskanta Swain wrote:
> Please help me in solving this issue. I want to check the write
> permissions on a directory on windows from my python script.
>
> I tried to use *os.access(dirpath, os.W_OK)*to check whether the user
> has write access or not, but it gives me incorrect result. It always
> gives me False even if the user has write permission. Interestingly this
> function works just fine on Linux platforms.

This is basically issue2528 [1].
The problem is that, although Windows (and Python)
expose a version of os.access to match the Posix function,
the meaning is so far removed on Windows as to be useless.

Really what you need to do is use the AccessCheck API, which
is a little bit tortuous, but is intended for this purpose.
You can look at the code in my patch for that issue to get
an idea of how to do it.

Does that help?

TJG


[1] http://bugs.python.org/issue2528

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: os.access giving incorrect results on Windows Tim Golden <mail@timgolden.me.uk> - 2011-05-19 20:43 +0100

csiph-web