Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / lib / python2.4 / stat.py
CommitLineData
86530b38
AT
1"""Constants/functions for interpreting results of os.stat() and os.lstat().
2
3Suggested usage: from stat import *
4"""
5
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).
10
11# Indices for stat struct members in tuple returned by os.stat()
12
13ST_MODE = 0
14ST_INO = 1
15ST_DEV = 2
16ST_NLINK = 3
17ST_UID = 4
18ST_GID = 5
19ST_SIZE = 6
20ST_ATIME = 7
21ST_MTIME = 8
22ST_CTIME = 9
23
24# Extract bits from the mode
25
26def S_IMODE(mode):
27 return mode & 07777
28
29def S_IFMT(mode):
30 return mode & 0170000
31
32# Constants used as S_IFMT() for various file types
33# (not all are implemented on all systems)
34
35S_IFDIR = 0040000
36S_IFCHR = 0020000
37S_IFBLK = 0060000
38S_IFREG = 0100000
39S_IFIFO = 0010000
40S_IFLNK = 0120000
41S_IFSOCK = 0140000
42
43# Functions to test for each file type
44
45def S_ISDIR(mode):
46 return S_IFMT(mode) == S_IFDIR
47
48def S_ISCHR(mode):
49 return S_IFMT(mode) == S_IFCHR
50
51def S_ISBLK(mode):
52 return S_IFMT(mode) == S_IFBLK
53
54def S_ISREG(mode):
55 return S_IFMT(mode) == S_IFREG
56
57def S_ISFIFO(mode):
58 return S_IFMT(mode) == S_IFIFO
59
60def S_ISLNK(mode):
61 return S_IFMT(mode) == S_IFLNK
62
63def S_ISSOCK(mode):
64 return S_IFMT(mode) == S_IFSOCK
65
66# Names for permission bits
67
68S_ISUID = 04000
69S_ISGID = 02000
70S_ENFMT = S_ISGID
71S_ISVTX = 01000
72S_IREAD = 00400
73S_IWRITE = 00200
74S_IEXEC = 00100
75S_IRWXU = 00700
76S_IRUSR = 00400
77S_IWUSR = 00200
78S_IXUSR = 00100
79S_IRWXG = 00070
80S_IRGRP = 00040
81S_IWGRP = 00020
82S_IXGRP = 00010
83S_IRWXO = 00007
84S_IROTH = 00004
85S_IWOTH = 00002
86S_IXOTH = 00001