General Purpose library for Freestanding C++ and POSIX systems
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

55 linhas
1.0 KiB

5 anos atrás
5 anos atrás
  1. #pragma once
  2. #include <fcntl.h>
  3. #include <unistd.h>
  4. #include <sys/mman.h>
  5. #include <sys/stat.h>
  6. #include <string>
  7. namespace gp{
  8. using open_opt_flags = int;
  9. enum class open_options : open_opt_flags {
  10. append = O_APPEND,
  11. create = O_CREAT,
  12. async = O_ASYNC,
  13. direct = O_DIRECT,
  14. data_sync = O_DSYNC,
  15. file_sync = O_SYNC,
  16. exclusive = O_EXCL,
  17. no_access_time = O_NOATIME,
  18. no_follow = O_NOFOLLOW,
  19. #ifdef O_TEMP
  20. temporary = O_TEMP,
  21. #endif
  22. #ifdef O_TRUC
  23. truncate = O_TRUC,
  24. #endif
  25. };
  26. using open_opt_mode = int;
  27. enum class open_modes : open_opt_mode {
  28. user_read = S_IRUSR,
  29. user_write = S_IWUSR,
  30. user_exec = S_IXUSR,
  31. group_read = S_IRGRP,
  32. group_write = S_IWGRP,
  33. group_exec = S_IXGRP,
  34. other_read = S_IROTH,
  35. other_write = S_IWOTH,
  36. other_exec = S_IXOTH,
  37. set_uid = S_ISUID,
  38. set_gid = S_ISGID,
  39. sticky_bit = S_ISVTX,
  40. };
  41. class shared_fd {
  42. const int fd;
  43. shared_fd(int fd_v)
  44. : fd(fd_v) {}
  45. public:
  46. static shared_fd open(const std::string& filename, const open_opt_flags& flags) {
  47. }
  48. };
  49. }