473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

predict directory write permission under windows?

I want to know if I can write files into a directory before I actually
perferm the write behavor. I found os.access(path, os.W_OK) but it uses
real uid/gid to check instead of euid/egid so it doesn't fit my problem.

I don't know how to get euid/egid under windows so I cannot use the mode
infomation returned by os.stat().

Anybody give me a hint?

Jul 18 '05 #1
2 1644
On Mon, 13 Dec 2004 22:14:03 +0800, rumours say that Qiangning Hong
<ho****@gmail.com> might have written:
I want to know if I can write files into a directory before I actually
perferm the write behavor. I found os.access(path, os.W_OK) but it uses
real uid/gid to check instead of euid/egid so it doesn't fit my problem.
I didn't even know that the notion of effective uid/gid existed on
windows. Unless that's a "service" from the Run as a different user
service, but I wouldn't know.
I don't know how to get euid/egid under windows so I cannot use the mode
infomation returned by os.stat(). Anybody give me a hint?


I won't be very helpful, but Python is mostly built around the
philosophy of asking forgiveness instead of permission (the opposite of
"look before you leap", which is what you want). There are other
typical arguments (what if permissions change between your check and the
actual write? what if the directory disappears before writing? etc)
which you might think they do not apply to you, but they most probably
do.

In case you want that to update some form of UI where the user should
know in advance, well, create a dummy file in the directory (and
instantly delete it) and report success or failure.

However, if you insist on knowing something that could be false, pywin32
might offer more functions to check for permissions.
--
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
Jul 18 '05 #2
My method isn't elegant, but I use tempfile to create a
tempfile in the directory (inside a try block). If it
works, closing the file makes it go away.

Larry Bates
Syscon, Inc.
Qiangning Hong wrote:
I want to know if I can write files into a directory before I actually
perferm the write behavor. I found os.access(path, os.W_OK) but it uses
real uid/gid to check instead of euid/egid so it doesn't fit my problem.

I don't know how to get euid/egid under windows so I cannot use the mode
infomation returned by os.stat().

Anybody give me a hint?

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
9
by: TPS | last post by:
I have a virtual directory where all posted files are stored. The ASP app does not have rights to the share on the other server where the vir dir resides. What is the best way to give the asp...
3
by: James Coleman | last post by:
Hello, The following error is appearing when attempting to create a directory using the availale system.io methods: System.IO.DirectoryNotFoundException: Could not find a part of the path...
7
by: Jaydeep | last post by:
Hi, Anybody knows how to create virtual directory programmatically under root directory ofcourse from code-behind. I am developing web-based application where I need to create a folder and making...
0
by: Jeremy | last post by:
I have an ASP.net application which needs to retreive images from multiple remote machines. It is reterieveing images generated by a web cam service on those machines. All of these machines,...
2
by: ykgoh | last post by:
Hi. I've a problem of being able to create and remove a directory but unable to write a file inside the created directory for some strange reason. I suspect that this problem could be vaguely...
3
by: Lucky | last post by:
Hi guys, after long long time. i'm back again with another problem. this time i think the problem is very very interesting and i really need you help on this. i'm trying to connect to the...
2
by: vishaltomar | last post by:
Hi, I post this question at a time when my neck is on the line. i have a problem in getting the directory permission using the -w operator. i need to get the permission before I run the xcopy...
6
by: Aussie Rules | last post by:
Hi, In my application I need to write an XML file to disk, but am concerned that permission might be a problem. The file only needs to be written out and used for another reason and can then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.