- bsddb: multithreaded DB access using the simple bsddb module interface
[python.git] / Lib / stat.py
blob70750d8b1ae909039c1e95d37ccab60b2f0096b0
1 """Constants/functions for interpreting results of os.stat() and os.lstat().
3 Suggested usage: from stat import *
4 """
6 # XXX Strictly spoken, this module may have to be adapted for each POSIX
7 # implementation; in practice, however, the numeric constants used by
8 # stat() are almost universal (even for stat() emulations on non-UNIX
9 # systems like MS-DOS).
11 # Indices for stat struct members in tuple returned by os.stat()
13 ST_MODE = 0
14 ST_INO = 1
15 ST_DEV = 2
16 ST_NLINK = 3
17 ST_UID = 4
18 ST_GID = 5
19 ST_SIZE = 6
20 ST_ATIME = 7
21 ST_MTIME = 8
22 ST_CTIME = 9
24 # Extract bits from the mode
26 def S_IMODE(mode):
27 return mode & 07777
29 def S_IFMT(mode):
30 return mode & 0170000
32 # Constants used as S_IFMT() for various file types
33 # (not all are implemented on all systems)
35 S_IFDIR = 0040000
36 S_IFCHR = 0020000
37 S_IFBLK = 0060000
38 S_IFREG = 0100000
39 S_IFIFO = 0010000
40 S_IFLNK = 0120000
41 S_IFSOCK = 0140000
43 # Functions to test for each file type
45 def S_ISDIR(mode):
46 return S_IFMT(mode) == S_IFDIR
48 def S_ISCHR(mode):
49 return S_IFMT(mode) == S_IFCHR
51 def S_ISBLK(mode):
52 return S_IFMT(mode) == S_IFBLK
54 def S_ISREG(mode):
55 return S_IFMT(mode) == S_IFREG
57 def S_ISFIFO(mode):
58 return S_IFMT(mode) == S_IFIFO
60 def S_ISLNK(mode):
61 return S_IFMT(mode) == S_IFLNK
63 def S_ISSOCK(mode):
64 return S_IFMT(mode) == S_IFSOCK
66 # Names for permission bits
68 S_ISUID = 04000
69 S_ISGID = 02000
70 S_ENFMT = S_ISGID
71 S_ISVTX = 01000
72 S_IREAD = 00400
73 S_IWRITE = 00200
74 S_IEXEC = 00100
75 S_IRWXU = 00700
76 S_IRUSR = 00400
77 S_IWUSR = 00200
78 S_IXUSR = 00100
79 S_IRWXG = 00070
80 S_IRGRP = 00040
81 S_IWGRP = 00020
82 S_IXGRP = 00010
83 S_IRWXO = 00007
84 S_IROTH = 00004
85 S_IWOTH = 00002
86 S_IXOTH = 00001