#include <hikogui/file/file_intf.hpp>
◆ file()
Open a file at location.
- Parameters
-
path | The path to the file to open. |
access_mode | access-mode to open the file. |
◆ close()
void hi::v1::file::close |
( |
| ) |
|
|
inline |
◆ flush()
void hi::v1::file::flush |
( |
| ) |
|
|
inline |
Flush and block until all data is physically written to disk.
Flushing is required before renaming a file, to prevent data corruption when the computer crashes during the rename.
◆ get_seek()
Get the current seek location.
◆ read()
Read data from a file.
- Parameters
-
data | Pointer to a buffer to read into. |
size | The number of bytes to read. |
- Returns
- The number of bytes read.
- Exceptions
-
◆ read_bstring()
bstring hi::v1::file::read_bstring |
( |
std::size_t | max_size = 10'000'000 | ) |
|
|
inline |
Read bytes from the file.
- Parameters
-
max_size | The maximum number of bytes to read. |
- Returns
- Data as a byte string, may return less then the requested size.
- Exceptions
-
◆ read_string()
Read a UTF-8 string from the file.
Because of complications with reading UTF-8 string with sequences it is only allowed to read from the start of the file.
- Note
- It is undefined bahavior when the seek pointer is not zero.
- Parameters
-
max_size | The maximum number of bytes to read. |
- Returns
- Data as a UTF-8 string, may return less then the requested size.
- Exceptions
-
◆ rename()
void hi::v1::file::rename |
( |
std::filesystem::path const & | destination, |
|
|
bool | overwrite_existing = true ) |
|
inline |
Rename an open file.
This function will rename an open file atomically.
- Parameters
-
destination | The destination file name. |
overwrite_existing | Overwrite an existing file. |
- Exceptions
-
◆ seek()
Set the seek location.
- Parameters
-
offset | To move the file pointer. |
whence | Where to seek from: begin, current or end |
- Returns
- The new seek position relative to the beginning of the file.
◆ size()
Return the size of the file.
◆ write() [1/5]
void hi::v1::file::write |
( |
bstring const & | text | ) |
|
|
inline |
Write data to a file.
- Parameters
-
text | The byte string to write |
- Exceptions
-
◆ write() [2/5]
void hi::v1::file::write |
( |
bstring_view | text | ) |
|
|
inline |
Write data to a file.
- Parameters
-
text | The byte string to write |
- Exceptions
-
◆ write() [3/5]
void hi::v1::file::write |
( |
std::span< std::byte const > | bytes | ) |
|
|
inline |
Write data to a file.
- Parameters
-
bytes | The byte string to write |
- Exceptions
-
◆ write() [4/5]
void hi::v1::file::write |
( |
std::string_view | text | ) |
|
|
inline |
Write data to a file.
- Parameters
-
text | The UTF-8 string to write |
- Exceptions
-
◆ write() [5/5]
void hi::v1::file::write |
( |
void const * | data, |
|
|
std::size_t | size ) |
|
inline |
Write data to a file.
- Parameters
-
data | Pointer to data to be written. |
size | The number of bytes to write. |
- Exceptions
-
The documentation for this class was generated from the following file: