![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
Class to wrap a directory handle. More...
Public Types | |
| enum class | unlink_type : std::uint8_t { directory , other } |
| Flag type to indicate what is being unlinked. More... | |
Public Member Functions | |
| directory_handle () noexcept | |
| Construct a directory handle that doesn't refer to a directory. | |
| directory_handle (directory_handle &&source) noexcept | |
Transfer ownership of a directory handle from source to *this. | |
| directory_handle (directory_handle const &)=delete | |
| Not copyable. | |
| directory_handle (file_handle source_handle) | |
| Obtain a directory handle from a file handle to the directory. | |
| ~directory_handle () | |
| Close the directory handle. | |
| 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-write handle to the new file. Fails if a file with the specified name already exists. | |
| auto | create_file (null_terminated_string_view relative_name, create_flags flags) const noexcept -> result< file_handle, error_code > |
Create a file or open an existing file with the specified name relative to the directory referenced by *this and return a read-write handle to the new file. The behaviour when there is already a file with the specified name is specified by the flags parameter. | |
| 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. | |
| 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 *this and return a read-write handle to the new file. Fails if a temporary file could not be created. | |
| 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 referenced by *this. | |
| 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 error if there are no more entries. | |
| 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 *this. | |
| auto | open_file (null_terminated_string_view const relative_name, open_flags const flags) const noexcept -> result< file_handle, error_code > |
Open a handle to the file with the specified name relative to the directory referenced by *this, with permissions specified by the flags. | |
| 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. | |
| auto | operator= (directory_handle &&source) noexcept -> directory_handle & |
Transfer ownership of a directory handle from source to *this. Closes any previous directory handle owned by *this. | |
| auto | operator= (directory_handle const &) -> directory_handle &=delete |
| Not copyable. | |
| 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 the specified new name relative to the directory referenced by *this. | |
| auto | rewind () noexcept -> result< void, error_code > |
| Rewind the directory handle to the start of the directory. | |
| 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. | |
| auto | valid () const noexcept -> bool |
| Check if the handle has a valid value. | |
Static Public Member Functions | |
| 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 working directory. | |
Class to wrap a directory handle.
|
strong |
|
inlinenoexcept |
Construct a directory handle that doesn't refer to a directory.
|
explicit |
Obtain a directory handle from a file handle to the directory.
| source_handle | The file handle for the directory |
| std::system_error | if an error occurs |
| arene::base::filesystem::directory_handle::~directory_handle | ( | ) |
Close the directory handle.
|
inlinenoexcept |
Transfer ownership of a directory handle from source to *this.
| source | The handle to transfer ownership from |
|
delete |
Not copyable.
|
noexcept |
Create a file with the specified name relative to the directory referenced by *this and return a read-write handle to the new file. Fails if a file with the specified name already exists.
| relative_name | The name of the file to create |
result holding a handle to the file if the file could be created, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Create a file or open an existing file with the specified name relative to the directory referenced by *this and return a read-write handle to the new file. The behaviour when there is already a file with the specified name is specified by the flags parameter.
| relative_name | The name of the file to create |
| flags | The creation flags |
result holding a handle to the file if the file could be created, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Create a directory as a subdirectory of the directory referenced by *this, with the given name.
| dir_name | The name of the new directory to create |
result with a value if the directory was created, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Create a temporary file with no name (or a transient random name) in the directory referenced by *this and return a read-write handle to the new file. Fails if a temporary file could not be created.
result holding a handle to the file if the file could be created, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Get the file stats for the directory entry with the specified name relative to the directory referenced by *this.
| relative_name | The name of the directory entry to check |
nullopt if the directory entry doesn't exist result holding the file stats for the directory entry if they could be retrieved, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Advance to the next directory entry and return it. Ignores "." and ".." entries. Returns an ERANGE error if there are no more entries.
result holding the name of the next entry on success, otherwise a result holding an error indicating the cause of failure. An error of ERANGE indicates that the end of the directory has been reached.
|
staticnoexcept |
Open a handle to the directory with the specified absolute path or path relative to the current working directory.
| path | The path of the directory to retrieve the handle for |
directory_handle for the directory, or nullopt if the directory doesn't exist result holding a handle to the directory if the directory could be opened, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Open a read-only handle to the file with the specified name relative to the directory referenced by *this.
| relative_name | The name of the file to open |
result holding a handle to the file if the file could be opened, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Open a handle to the file with the specified name relative to the directory referenced by *this, with permissions specified by the flags.
| relative_name | The name of the file to open |
| flags | The flags to use for opening the file |
result holding a handle to the file if the file could be opened, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Open a handle to the directory with the specified name relative to the directory referenced by *this.
| relative_name | The name of the directory to retrieve the handle for |
result holding a handle to the subdirectory if the directory could be opened, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Transfer ownership of a directory handle from source to *this. Closes any previous directory handle owned by *this.
| source | The handle to transfer ownership from |
|
delete |
Not copyable.
|
noexcept |
Rename a file or directory from its existing name relative to the directory referenced by *this to the specified new name relative to the directory referenced by *this.
| old_name | The existing name of the file or directory |
| new_name | The desired name of the file or directory |
result holding a value if the file or directory could be renamed, otherwise a result holding an error_code identifying the cause for the failure.
|
noexcept |
Rewind the directory handle to the start of the directory.
result holding a value on success, otherwise a result holding an error indicating the cause of failure.
|
noexcept |
Remove a directory entry with the specified name relative to the directory referenced by *this.
| relative_name | The name of the directory entry to check |
| type | A flag indicating if the directory entry is thought to be a directory (unlink_type::directory), or not (unlink_type::other) |
result with a value if the directory entry was removed, otherwise a result holding an error_code identifying the cause for the failure.
|
inlinenoexcept |
Check if the handle has a valid value.
true if the handle is valid, false otherwise