OT - file permission checks on Windows

Skip Montanaro skip at pobox.com
Mon Mar 4 13:26:44 EST 2002


Sorry for the off-topic post.  My entire C programming world these days is
in the Python community, so I'm completely disconnected from other C
programming resources.  (Pointer to information about porting Unix code to
MSVC would be much appreciated.)  

Given this simple file access permission code:

    mode_check(struct stat *buf, uid_t uid, uid_t gid,
               unsigned int umask, unsigned int gmask, unsigned int omask)
    {
        /* root always gets to go */
        if (uid == 0) return 1;

        if (uid == buf->st_uid) return buf->st_mode & umask;

        if (gid == buf->st_gid) return buf->st_mode & gmask;

        return buf->st_mode & omask;
    }

how would I do this under Windows?  Is the permission model there even
remotely similar to what I'm used to on Unix systems?  I poked around
posixmodule.c, but it makes next to no use of uids and gids.  As far as I
can tell, Windows doesn't know about uid_t or gid_t, though it has a struct
_stat type whose st_uid and st_gid fields are shorts, so I can work around
the missing types.

Thx,

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list