symbian-qemu-0.9.1-12/python-2.6.1/Lib/stat.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 """Constants/functions for interpreting results of os.stat() and os.lstat().
       
     2 
       
     3 Suggested usage: from stat import *
       
     4 """
       
     5 
       
     6 # Indices for stat struct members in the tuple returned by os.stat()
       
     7 
       
     8 ST_MODE  = 0
       
     9 ST_INO   = 1
       
    10 ST_DEV   = 2
       
    11 ST_NLINK = 3
       
    12 ST_UID   = 4
       
    13 ST_GID   = 5
       
    14 ST_SIZE  = 6
       
    15 ST_ATIME = 7
       
    16 ST_MTIME = 8
       
    17 ST_CTIME = 9
       
    18 
       
    19 # Extract bits from the mode
       
    20 
       
    21 def S_IMODE(mode):
       
    22     return mode & 07777
       
    23 
       
    24 def S_IFMT(mode):
       
    25     return mode & 0170000
       
    26 
       
    27 # Constants used as S_IFMT() for various file types
       
    28 # (not all are implemented on all systems)
       
    29 
       
    30 S_IFDIR  = 0040000
       
    31 S_IFCHR  = 0020000
       
    32 S_IFBLK  = 0060000
       
    33 S_IFREG  = 0100000
       
    34 S_IFIFO  = 0010000
       
    35 S_IFLNK  = 0120000
       
    36 S_IFSOCK = 0140000
       
    37 
       
    38 # Functions to test for each file type
       
    39 
       
    40 def S_ISDIR(mode):
       
    41     return S_IFMT(mode) == S_IFDIR
       
    42 
       
    43 def S_ISCHR(mode):
       
    44     return S_IFMT(mode) == S_IFCHR
       
    45 
       
    46 def S_ISBLK(mode):
       
    47     return S_IFMT(mode) == S_IFBLK
       
    48 
       
    49 def S_ISREG(mode):
       
    50     return S_IFMT(mode) == S_IFREG
       
    51 
       
    52 def S_ISFIFO(mode):
       
    53     return S_IFMT(mode) == S_IFIFO
       
    54 
       
    55 def S_ISLNK(mode):
       
    56     return S_IFMT(mode) == S_IFLNK
       
    57 
       
    58 def S_ISSOCK(mode):
       
    59     return S_IFMT(mode) == S_IFSOCK
       
    60 
       
    61 # Names for permission bits
       
    62 
       
    63 S_ISUID = 04000
       
    64 S_ISGID = 02000
       
    65 S_ENFMT = S_ISGID
       
    66 S_ISVTX = 01000
       
    67 S_IREAD = 00400
       
    68 S_IWRITE = 00200
       
    69 S_IEXEC = 00100
       
    70 S_IRWXU = 00700
       
    71 S_IRUSR = 00400
       
    72 S_IWUSR = 00200
       
    73 S_IXUSR = 00100
       
    74 S_IRWXG = 00070
       
    75 S_IRGRP = 00040
       
    76 S_IWGRP = 00020
       
    77 S_IXGRP = 00010
       
    78 S_IRWXO = 00007
       
    79 S_IROTH = 00004
       
    80 S_IWOTH = 00002
       
    81 S_IXOTH = 00001
       
    82 
       
    83 # Names for file flags
       
    84 
       
    85 UF_NODUMP    = 0x00000001
       
    86 UF_IMMUTABLE = 0x00000002
       
    87 UF_APPEND    = 0x00000004
       
    88 UF_OPAQUE    = 0x00000008
       
    89 UF_NOUNLINK  = 0x00000010
       
    90 SF_ARCHIVED  = 0x00010000
       
    91 SF_IMMUTABLE = 0x00020000
       
    92 SF_APPEND    = 0x00040000
       
    93 SF_NOUNLINK  = 0x00100000
       
    94 SF_SNAPSHOT  = 0x00200000