filearr.hpp 962 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <memory>
  3. #include "dentry.hpp"
  4. #include "file.hpp"
  5. namespace fs {
  6. class filearray {
  7. private:
  8. struct impl;
  9. std::shared_ptr<impl> pimpl;
  10. filearray(std::shared_ptr<impl>);
  11. public:
  12. filearray();
  13. filearray(filearray&& other) = default;
  14. filearray copy() const;
  15. filearray share() const;
  16. // dup old_fd to some random fd
  17. int dup(int old_fd);
  18. // dup old_fd to new_fd, close new_fd if it is already open
  19. int dup(int old_fd, int new_fd, int flags);
  20. // dup old_fd to the first available fd starting from min_fd
  21. int dupfd(int fd, int min_fd, int flags);
  22. fs::file* operator[](int i) const;
  23. int set_flags(int fd, int flags);
  24. int pipe(int (&pipefd)[2]);
  25. int open(dentry& root, const types::path& filepath, int flags, mode_t mode);
  26. int close(int fd);
  27. // any call to member methods will be invalid after clear()
  28. void clear();
  29. void onexec();
  30. };
  31. } // namespace fs