#pragma once #include #include #include #include #include #include namespace os { class File { public: enum OpenMode { ReadOnly = O_RDONLY, WriteOnly = O_WRONLY | O_TRUNC, ReadWrite = O_RDWR | O_TRUNC, Append = O_WRONLY | O_APPEND, ReadAppend = O_RDWR | O_APPEND, }; static Result> open(StringView path, OpenMode flags); static Result> open_or_create(StringView path, OpenMode flags, mode_t mode = 0644); static Result> create(StringView path, OpenMode flags, mode_t mode = 0644); void set_close_on_exec(); Result write(StringView str); File(Badge); ~File(); private: static Result> construct(StringView path, int flags, mode_t mode); Result raw_read(u8* buf, usize length); Result raw_write(const u8* buf, usize length); int m_fd { -1 }; }; }