5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FILESYSTEM_DIRECTORY_HANDLE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FILESYSTEM_DIRECTORY_HANDLE_HPP_
44 using os_directory_handle = int;
233 os_directory_handle raw_handle_;
Class to wrap a directory handle.
Definition directory_handle.hpp:41
unlink_type
Flag type to indicate what is being unlinked.
Definition directory_handle.hpp:139
@ directory
A directory is being unlinked.
Definition directory_handle.hpp:141
@ other
Something that is not a directory is being unlinked.
Definition directory_handle.hpp:143
auto unlink_entry(null_terminated_string_view const relative_name, unlink_type const type) const noexcept -> result< void, error_code >
Remove a directory entry with the specified name relative to the directory referenced by *this.
Definition directory_handle.cpp:246
auto rewind() noexcept -> result< void, error_code >
Rewind the directory handle to the start of the directory.
Definition directory_handle.cpp:136
auto create_temporary_file() const noexcept -> result< file_handle, error_code >
Create a temporary file with no name (or a transient random name) in the directory referenced by *thi...
Definition directory_handle.cpp:400
auto operator=(directory_handle &&source) noexcept -> directory_handle &
Transfer ownership of a directory handle from source to *this. Closes any previous directory handle o...
Definition directory_handle.cpp:126
auto operator=(directory_handle const &) -> directory_handle &=delete
Not copyable.
auto create_file(null_terminated_string_view const relative_name) const noexcept -> result< file_handle, error_code >
Create a file with the specified name relative to the directory referenced by *this and return a read...
Definition directory_handle.cpp:321
auto get_file_stats(null_terminated_string_view const relative_name) const noexcept -> result< struct stat, error_code >
Get the file stats for the directory entry with the specified name relative to the directory referenc...
Definition directory_handle.cpp:233
auto create_subdirectory(null_terminated_string_view const dir_name) const noexcept -> result< void, error_code >
Create a directory as a subdirectory of the directory referenced by *this, with the given name.
Definition directory_handle.cpp:180
auto open_file(null_terminated_string_view const relative_name) const noexcept -> result< file_handle, error_code >
Open a read-only handle to the file with the specified name relative to the directory referenced by *...
Definition directory_handle.cpp:258
auto open_subdirectory(null_terminated_string_view const relative_name) const noexcept -> result< directory_handle, error_code >
Open a handle to the directory with the specified name relative to the directory referenced by *this.
Definition directory_handle.cpp:215
~directory_handle()
Close the directory handle.
Definition directory_handle.cpp:117
auto next_entry() noexcept -> result< null_terminated_string_view, error_code >
Advance to the next directory entry and return it. Ignores "." and ".." entries. Returns an ERANGE er...
Definition directory_handle.cpp:148
auto valid() const noexcept -> bool
Check if the handle has a valid value.
Definition directory_handle.hpp:74
auto rename(null_terminated_string_view const old_name, null_terminated_string_view const new_name) const noexcept -> result< void, error_code >
Rename a file or directory from its existing name relative to the directory referenced by *this to th...
Definition directory_handle.cpp:386
directory_handle() noexcept
Construct a directory handle that doesn't refer to a directory.
Definition directory_handle.hpp:48
directory_handle(directory_handle &&source) noexcept
Transfer ownership of a directory handle from source to *this.
Definition directory_handle.hpp:62
static auto open(null_terminated_string_view const path) noexcept -> result< directory_handle, error_code >
Open a handle to the directory with the specified absolute path or path relative to the current worki...
Definition directory_handle.cpp:201
directory_handle(directory_handle const &)=delete
Not copyable.
A class representing a filesystem error value. Intended to be a wrapper around errno.
Definition error_code.hpp:33
An RAII wrapper around a POSIX file handle with unique-ownership semantics.
Definition file_handle.hpp:26
static constexpr os_file_handle invalid_handle_value
An invalid handle value.
Definition file_handle.hpp:35
A read-only string-view that provides a view onto a null-terminated string.
Definition null_terminated_string_view.hpp:62
A sum type which can hold either a value or an error. Similar to std::expected.
Definition result.hpp:104
Definition directory_handle.cpp:39
create_flags
Flags to specify what to do when attempting to create a file that already exists.
Definition directory_handle.hpp:30
@ create_or_open
If the file already exists, open the existing file without altering it.
Definition directory_handle.hpp:36
@ create_or_truncate
If the file already exists, truncate it and open it.
Definition directory_handle.hpp:34
@ create_or_fail
If the file already exists fail the creation.
Definition directory_handle.hpp:32
open_flags
An enumeration specifying choices for opening files.
Definition open_flags.hpp:15
Definition accumulate.hpp:37
::std::uint8_t uint8_t
An 8-bit unsigned integer type.
Definition integer_types.hpp:17
Definition accumulate.hpp:36
::uint8_t uint8_t
An 8-bit unsigned integer type.
Definition cstdint.hpp:30
constexpr auto exchange(T &target, U &&source) noexcept(is_nothrow_move_constructible_v< T > &&is_nothrow_assignable_v< T &, U && >) -> T
Assign a new value to an object and return the old value. Implements std::exchange.
Definition exchange.hpp:33
Public export header for the result subpackage.
Public export header for the string_view subpackage.