cython

Форк
0
98 строк · 2.6 Кб
1
# https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html
2
# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
3

4
from posix.types cimport (blkcnt_t, blksize_t, dev_t, gid_t, ino_t, mode_t,
5
                          nlink_t, off_t, time_t, uid_t)
6
from posix.time cimport timespec
7

8

9
cdef extern from "<sys/stat.h>" nogil:
10
    cdef struct struct_stat "stat":
11
        dev_t   st_dev
12
        ino_t   st_ino
13
        mode_t  st_mode
14
        nlink_t st_nlink
15
        uid_t   st_uid
16
        gid_t   st_gid
17
        dev_t   st_rdev
18
        off_t   st_size
19
        blksize_t st_blksize
20
        blkcnt_t st_blocks
21
        # POSIX.1-2001
22
        time_t  st_atime
23
        time_t  st_mtime
24
        time_t  st_ctime
25
        # POSIX.1-2008
26
        timespec st_atim
27
        timespec st_mtim
28
        timespec st_ctim
29

30
        # st_birthtime exists on *BSD and OS X.
31
        # Under Linux, defining it here does not hurt. Compilation under Linux
32
        # will only (and rightfully) fail when attempting to use the field.
33
        time_t  st_birthtime
34

35
# POSIX prescribes including both <sys/stat.h> and <unistd.h> for these
36
cdef extern from "<unistd.h>" nogil:
37
    int chmod(const char *, mode_t)
38
    int fchmod(int, mode_t)
39
    int fchmodat(int, const char *, mode_t, int flags)
40

41
    int stat(const char *, struct_stat *)
42
    int lstat(const char *, struct_stat *)
43
    int fstat(int, struct_stat *)
44
    int fstatat(int, const char *, struct_stat *, int flags)
45

46
    int mkdir(const char *, mode_t)
47
    int mkdirat(int, const char *, mode_t)
48
    int mkfifo(const char *, mode_t)
49
    int mkfifoat(int, const char *, mode_t)
50
    int mknod(const char *, mode_t, dev_t)
51
    int mknodat(int, const char *, mode_t, dev_t)
52

53
    int futimens(int, const timespec *)
54
    int utimensat(int, const char *, const timespec *, int flags)
55

56
    # Macros for st_mode
57
    mode_t S_ISREG(mode_t)
58
    mode_t S_ISDIR(mode_t)
59
    mode_t S_ISCHR(mode_t)
60
    mode_t S_ISBLK(mode_t)
61
    mode_t S_ISFIFO(mode_t)
62
    mode_t S_ISLNK(mode_t)
63
    mode_t S_ISSOCK(mode_t)
64

65
    mode_t S_IFMT
66
    mode_t S_IFREG
67
    mode_t S_IFDIR
68
    mode_t S_IFCHR
69
    mode_t S_IFBLK
70
    mode_t S_IFIFO
71
    mode_t S_IFLNK
72
    mode_t S_IFSOCK
73

74
    # Permissions
75
    mode_t S_ISUID
76
    mode_t S_ISGID
77
    mode_t S_ISVTX
78

79
    mode_t S_IRWXU
80
    mode_t S_IRUSR
81
    mode_t S_IWUSR
82
    mode_t S_IXUSR
83

84
    mode_t S_IRWXG
85
    mode_t S_IRGRP
86
    mode_t S_IWGRP
87
    mode_t S_IXGRP
88

89
    mode_t S_IRWXO
90
    mode_t S_IROTH
91
    mode_t S_IWOTH
92
    mode_t S_IXOTH
93

94
    # test file types
95
    bint S_TYPEISMQ(struct_stat *buf)
96
    bint S_TYPEISSEM(struct_stat *buf)
97
    bint S_TYPEISSHM(struct_stat *buf)
98
    bint S_TYPEISTMO(struct_stat *buf)
99

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.