Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11267 > unrolled thread
| Started by | Tim Golden <mail@timgolden.me.uk> |
|---|---|
| First post | 2011-08-12 11:52 +0100 |
| Last post | 2011-08-12 11:52 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to Check Write Access of a Folder on Windows Tim Golden <mail@timgolden.me.uk> - 2011-08-12 11:52 +0100
| From | Tim Golden <mail@timgolden.me.uk> |
|---|---|
| Date | 2011-08-12 11:52 +0100 |
| Subject | Re: How to Check Write Access of a Folder on Windows |
| Message-ID | <mailman.2216.1313146373.1164.python-list@python.org> |
On 12/08/2011 11:41, Ayaskanta Swain wrote: > Hi, > > I have a requirement where I need to check the write permissions on a > directory on Windows platform. I don’t want to use the python function > os.access( ), since it does not work correctly on Windows. It is giving > incorrect results to me. > > Another option of actually creating a temporary file inside the folder & > then deleting it to check whether the user has write permissions or not > is causing performance issues. It is slowing down our application when > we have to check the permissions on hundreds of folders. It also changes > the last access time stamp of the folder. > > So is there any other way such as using Win32API or Win32 security > modules to check the permissions? In general, yes. Depends how finnicky you want to get. I take it from your question that you're pretty much unfamiliar with the Windows Security APIs and structures? There's a quite a bit of information around on the subject, but have a look at this first which is at least Python-oriented: http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html The trouble is that do what you want, you need to use the AccessCheck API (or emulate its functionality) and this isn't currently exposed by the pywin32 modules. You could run it up yourself with ctypes or by creating a quick extension for the purpose. Alternatively, as I say, you could emulate by scanning the ACLs/ACEs and trying to apply some suitable logic. Frankly, I'd have thought this was harder work :) Hope that helps TJG
Back to top | Article view | comp.lang.python
csiph-web