Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b47ed1

Browse files
committed
Initial revision
1 parent 2dbf39c commit 6b47ed1

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lib/stat.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Module 'stat'
2+
3+
# Defines constants and functions for interpreting stat/lstat struct
4+
# as returned by posix.stat() and posix.lstat() (if it exists).
5+
6+
# XXX This module may have to be adapted for UNIXoid systems whose
7+
# <sys/stat.h> deviates from AT&T or BSD UNIX; their S_IF* constants
8+
# may differ.
9+
10+
# Suggested usage: from stat import *
11+
12+
# Tuple indices for stat struct members
13+
14+
ST_MODE = 0
15+
ST_INO = 1
16+
ST_DEV = 2
17+
ST_NLINK = 3
18+
ST_UID = 4
19+
ST_GID = 5
20+
ST_SIZE = 6
21+
ST_ATIME = 7
22+
ST_MTIME = 8
23+
ST_CTIME = 9
24+
25+
def S_IFMT(mode):
26+
return mode - mode%4096
27+
28+
S_IFDIR = 0040000
29+
S_IFCHR = 0020000
30+
S_IFBLK = 0060000
31+
S_IFREG = 0100000
32+
S_IFIFO = 0010000
33+
S_IFLNK = 0120000
34+
S_IFSOCK = 0140000
35+
36+
def S_ISDIR(mode):
37+
return S_IFMT(mode) = S_IFDIR
38+
39+
def S_ISCHR(mode):
40+
return S_IFMT(mode) = S_IFCHR
41+
42+
def S_ISBLK(mode):
43+
return S_IFMT(mode) = S_IFBLK
44+
45+
def S_ISREG(mode):
46+
return S_IFMT(mode) = S_IFREG
47+
48+
def S_ISFIFO(mode):
49+
return S_IFMT(mode) = S_IFIFO
50+
51+
def S_ISLNK(mode):
52+
return S_IFMT(mode) = S_IFLNK
53+
54+
def S_ISSOCK(mode):
55+
return S_IFMT(mode) = S_IFSOCK

0 commit comments

Comments
 (0)