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


Groups > comp.lang.python > #20977

Re: check if directory is writable in a portable way

Date 2012-02-28 06:12 -0600
From Tim Chase <python.list@tim.thechases.com>
Subject Re: check if directory is writable in a portable way
References <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> <4F4CC1FC.40502@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.224.1330431141.3037.python-list@python.org> (permalink)

Show all headers | View raw


On 02/28/12 06:01, Andrea Crotti wrote:
>>> How should I check if I can create files in a directory?
>
> But isn't there (or should there be) a windows-related library that
> abstracts this horrible things?

Yes, there should be. There isn't as far as I know (though that 
doesn't mean much given my limited experiences in the recesses of 
Win32 APIs).

Additionally, even if you did a LBYL instead, you'd open yourself 
to a race-condition where the permissions could theoretically 
change between the time you check and the time you actually try 
to write there.  Granted, that's a slim chance and usually would 
be a "Doctor, my foot hurts when I do $THIS"/"Well don't do that" 
situation where the solution is "don't change the permissions 
while running this program".

-tkc


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


Thread

Re: check if directory is writable in a portable way Tim Chase <python.list@tim.thechases.com> - 2012-02-28 06:12 -0600

csiph-web