12#include DIUS_PLATFORM_PATH(system_call.h)
15#ifdef DIUS_PLATFORM_LINUX
16enum class Protection :
int {
20 Writeable = PROT_WRITE,
25enum class MapFlags :
int {
28 Private = MAP_PRIVATE,
30 Anonymous = MAP_ANONYMOUS,
33 Populate = MAP_POPULATE,
46 constexpr explicit SyncFile(
Owned owned,
int fd) : m_owned(owned), m_fd(fd) {}
65 constexpr auto valid() const ->
bool {
return m_fd != -1; }
66 constexpr explicit operator bool()
const {
return valid(); }
88#ifdef DIUS_PLATFORM_LINUX
89 auto map(
u64 offset,
size_t size, Protection protection, MapFlags flags)
const
#define DI_DEFINE_ENUM_BITWISE_OPERATIONS(Type)
Definition bitwise_enum.h:5
Definition function.h:365
Definition scope_exit.h:12
Definition expected_forward_declaration.h:8
Definition span_forward_declaration.h:10
Definition sync_file.h:40
constexpr ~SyncFile()
Definition sync_file.h:51
constexpr auto valid() const -> bool
Definition sync_file.h:65
constexpr SyncFile()=default
auto read_exactly(u64 offset, di::Span< di::Byte >) const -> di::Expected< void, di::GenericCode >
Definition sync_file.cpp:6
constexpr SyncFile(Owned owned, int fd)
Definition sync_file.h:46
auto get_tty_window_size() -> di::Expected< tty::WindowSize, di::GenericCode >
Definition sync_file.cpp:64
auto resize_file(u64 new_size) const -> di::Expected< void, di::GenericCode >
Definition sync_file.cpp:56
auto enter_raw_mode() -> di::Expected< RawModeToken, di::GenericCode >
Definition sync_file.cpp:72
auto operator=(SyncFile &&other) -> SyncFile &
Definition sync_file.h:58
auto read_some(u64 offset, di::Span< di::Byte >) const -> di::Expected< size_t, di::GenericCode >
Definition sync_file.cpp:44
constexpr SyncFile(SyncFile &&other)
Definition sync_file.h:48
constexpr auto file_descriptor() const -> int
Definition sync_file.h:68
auto flush() const -> di::Expected< void, di::GenericCode >
Definition sync_file.h:93
constexpr auto leak_file_descriptor() -> int
Definition sync_file.h:69
auto close() -> di::Expected< void, di::GenericCode >
Definition sync_file.cpp:30
auto set_tty_window_size(tty::WindowSize size) -> di::Expected< void, di::GenericCode >
Definition sync_file.cpp:60
Owned
Definition sync_file.h:42
@ Yes
Definition sync_file.h:42
@ No
Definition sync_file.h:42
auto interactive_device() const -> bool
Definition sync_file.h:95
auto write_exactly(u64 offset, di::Span< di::Byte const >) const -> di::Expected< void, di::GenericCode >
Definition sync_file.cpp:29
di::ScopeExit< di::Function< void()> > RawModeToken
Definition sync_file.h:101
auto get_psuedo_terminal_path() -> di::Expected< di::Path, di::GenericCode >
Definition sync_file.cpp:68
auto write_some(u64 offset, di::Span< di::Byte const >) const -> di::Expected< size_t, di::GenericCode >
Definition sync_file.cpp:52
constexpr usize size
Definition gfx_test.cpp:24
@ Readable
Definition file_implementation.h:47
@ None
Definition file_implementation.h:46
PathViewImpl< string::TransparentEncoding > PathView
Definition path_view.h:11
Stack(Con) -> Stack< T, Con >
@ Executable
Definition program_header.h:23
__UINT64_TYPE__ u64
Definition integers.h:12
__UINT16_TYPE__ u16
Definition integers.h:10
Expected< T, Error > Result
Definition result.h:8
StatusCode< platform::GenericDomain > GenericCode
Definition status_code_forward_declaration.h:13
Definition zstring_parser.h:9
constexpr auto exchange(T &object, U &&new_value) -> T
Definition exchange.h:8
Definition directory_entry.h:11
auto stderr
Definition sync_file.h:120
auto open_psuedo_terminal_controller(OpenMode open_mode, tty::WindowSize size) -> di::Expected< SyncFile, di::GenericCode >
Definition sync_file.cpp:95
auto open_sync(di::PathView path, OpenMode open_mode, u16 create_mode=0666) -> di::Expected< SyncFile, di::GenericCode >
Definition sync_file.cpp:76
auto read_to_string(di::PathView path) -> di::Result< di::String >
Definition sync_file.cpp:52
auto open_tempory_file() -> di::Expected< SyncFile, di::GenericCode >
Definition sync_file.cpp:99
auto stdout
Definition sync_file.h:119
OpenMode
Definition sync_file.h:109
@ Readonly
Definition sync_file.h:109
@ WriteNew
Definition sync_file.h:109
@ AppendOnly
Definition sync_file.h:109
@ AppendReadWrite
Definition sync_file.h:109
@ ReadWrite
Definition sync_file.h:109
@ WriteClobber
Definition sync_file.h:109
@ ReadWriteClobber
Definition sync_file.h:109
auto stdin
Definition sync_file.h:118
@ Fixed
Definition local_apic.h:82