stat.pxd 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from posix.types cimport (blkcnt_t, blksize_t, dev_t, gid_t, ino_t, mode_t,
  2. nlink_t, off_t, time_t, uid_t)
  3. cdef extern from "<sys/stat.h>" nogil:
  4. cdef struct struct_stat "stat":
  5. dev_t st_dev
  6. ino_t st_ino
  7. mode_t st_mode
  8. nlink_t st_nlink
  9. uid_t st_uid
  10. gid_t st_gid
  11. dev_t st_rdev
  12. off_t st_size
  13. blksize_t st_blksize
  14. blkcnt_t st_blocks
  15. time_t st_atime
  16. time_t st_mtime
  17. time_t st_ctime
  18. # st_birthtime exists on *BSD and OS X.
  19. # Under Linux, defining it here does not hurt. Compilation under Linux
  20. # will only (and rightfully) fail when attempting to use the field.
  21. time_t st_birthtime
  22. # POSIX prescribes including both <sys/stat.h> and <unistd.h> for these
  23. cdef extern from "<unistd.h>" nogil:
  24. int fchmod(int, mode_t)
  25. int chmod(const char *, mode_t)
  26. int fstat(int, struct_stat *)
  27. int lstat(const char *, struct_stat *)
  28. int stat(const char *, struct_stat *)
  29. # Macros for st_mode
  30. mode_t S_ISREG(mode_t)
  31. mode_t S_ISDIR(mode_t)
  32. mode_t S_ISCHR(mode_t)
  33. mode_t S_ISBLK(mode_t)
  34. mode_t S_ISFIFO(mode_t)
  35. mode_t S_ISLNK(mode_t)
  36. mode_t S_ISSOCK(mode_t)
  37. mode_t S_IFMT
  38. mode_t S_IFREG
  39. mode_t S_IFDIR
  40. mode_t S_IFCHR
  41. mode_t S_IFBLK
  42. mode_t S_IFIFO
  43. mode_t S_IFLNK
  44. mode_t S_IFSOCK
  45. # Permissions
  46. mode_t S_ISUID
  47. mode_t S_ISGID
  48. mode_t S_ISVTX
  49. mode_t S_IRWXU
  50. mode_t S_IRUSR
  51. mode_t S_IWUSR
  52. mode_t S_IXUSR
  53. mode_t S_IRWXG
  54. mode_t S_IRGRP
  55. mode_t S_IWGRP
  56. mode_t S_IXGRP
  57. mode_t S_IRWXO
  58. mode_t S_IROTH
  59. mode_t S_IWOTH
  60. mode_t S_IXOTH