predict directory write permission under windows?

Discussion in 'Python' started by Qiangning Hong, Dec 13, 2004.

  1. 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?
     
    Qiangning Hong, Dec 13, 2004
    #1
    1. Advertising

  2. On Mon, 13 Dec 2004 22:14:03 +0800, rumours say that Qiangning Hong
    <> 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...
     
    Christos TZOTZIOY Georgiou, Dec 13, 2004
    #2
    1. Advertising

  3. Qiangning Hong

    Larry Bates Guest

    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?
    >
     
    Larry Bates, Dec 13, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amir  Michail
    Replies:
    0
    Views:
    365
    Amir Michail
    Jan 14, 2005
  2. Amir  Michail
    Replies:
    1
    Views:
    349
    Andrew Thompson
    Jan 14, 2005
  3. Replies:
    6
    Views:
    5,807
    John W. Kennedy
    Jul 17, 2006
  4. __schronos__

    Change directory permission under windows

    __schronos__, Nov 8, 2006, in forum: Python
    Replies:
    0
    Views:
    292
    __schronos__
    Nov 8, 2006
  5. __schronos__

    Change directory permission under windows

    __schronos__, Nov 8, 2006, in forum: Python
    Replies:
    1
    Views:
    353
    Roger Upole
    Nov 8, 2006
Loading...

Share This Page