sysstat.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "defaults.h"
  3. #include <sys/stat.h>
  4. #ifdef _win_
  5. #define S_IRUSR _S_IREAD
  6. #define S_IWUSR _S_IWRITE
  7. #define S_IXUSR _S_IEXEC
  8. #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
  9. #define S_IRGRP _S_IREAD
  10. #define S_IWGRP _S_IWRITE
  11. #define S_IXGRP _S_IEXEC
  12. #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
  13. #define S_IROTH _S_IREAD
  14. #define S_IWOTH _S_IWRITE
  15. #define S_IXOTH _S_IEXEC
  16. #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
  17. #endif
  18. int Chmod(const char* fname, int mode);
  19. int Umask(int mode);
  20. static constexpr int MODE0777 = (S_IRWXU | S_IRWXG | S_IRWXO);
  21. static constexpr int MODE0775 = (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  22. static constexpr int MODE0755 = (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
  23. int Mkdir(const char* path, int mode);
  24. /* uff... mkfifo(...) is not used now */
  25. #ifdef _unix_
  26. inline int Chmod(const char* fname, int mode) {
  27. return ::chmod(fname, mode);
  28. }
  29. inline int Umask(int mode) {
  30. return ::umask(mode);
  31. }
  32. inline int Mkdir(const char* path, int mode) {
  33. return ::mkdir(path, mode);
  34. }
  35. #endif
  36. #ifdef _win_
  37. inline int Umask(int /*mode*/) {
  38. /* The only thing this method could make is to set FILE_ATTRIBUTE_READONLY on a handle from 'int open(...)',
  39. but open() is deprecated. */
  40. return 0;
  41. }
  42. #endif