Generic boxed unique handle to a writable file in any filesystem.
More...
#include <GREM/core/system/File.hpp>
Generic boxed unique handle to a writable file in any filesystem.
◆ OutputFileHandle()
| grem::OutputFileHandle::OutputFileHandle |
( |
| ) |
|
|
defaultnoexcept |
Construct a null file handle without an associated file.
◆ create()
template<typename Implementation, typename... Args>
Create a boxed file with a specific implementation.
- Template Parameters
-
| Implementation | concrete file type. |
- Parameters
-
| args | arguments to forward to the concrete file constructor. |
- Returns
- the new boxed file.
- Exceptions
-
| any | exception thrown by the concrete file's constructor. |
| std::bad_alloc | on allocation failure. |
◆ operator Writer()
Get a writer for the underlying file interface.
- Returns
- a writer for the underlying file interface.
- Warning
- The file handle must not be null.
◆ get() [1/2]
Get a pointer to the underlying file interface.
- Returns
- a non-owning pointer to the underlying file interface.
◆ get() [2/2]
Get a pointer to the underlying file interface.
- Returns
- a non-owning read-only pointer to the underlying file interface.
◆ operator OutputFile &()
Get a reference to the underlying file interface.
- Returns
- a reference to the underlying file interface.
- Warning
- The file handle must not be null.
◆ operator const OutputFile &()
Get a reference to the underlying file interface.
- Returns
- a read-only reference to the underlying file interface.
- Warning
- The file handle must not be null.
◆ operator bool()
Check if the file handle has an open file associated with it.
- Returns
- true if there is an associated open file, false otherwise.
◆ close()
Close the associated file so that it can no longer be accessed through this handle, and reset the handle to a closed file handle without an associated file.
- Exceptions
-
| File::Error | on failure to close the file. |
| std::bad_alloc | on allocation failure. |
- Note
- This function has no effect if the handle has no open file associated with it.
◆ isOpen()
Check if the file handle has an open file associated with it.
- Returns
- true if there is an associated open file, false otherwise.
◆ tellp()
Get the current writing position of the file.
- Returns
- the current file writing position, or File::npos if it cannot be determined.
◆ seekp()
Set the file writing position to an absolute offset from the beginning of the file.
- Parameters
-
| position | the new writing position to set. |
- Exceptions
-
- Note
- Attempting to seek to a position outside the readable length of the file will cause the function to fail.
◆ skipp()
Advance the file writing position by a relative offset, which may be negative in order to go backwards.
- Parameters
-
| offset | the relative offset to advance the writing position by. |
- Exceptions
-
- Note
- Attempting to seek to a position outside the readable length of the file will cause the function to fail.
◆ writeSome()
Write data to the end of an open file from a buffer.
The writing position is advanced to the new end of the file.
- Parameters
-
| data | read-only view over the buffer to copy the data from. The size of the buffer determines the number of bytes that are attempted to be written. |
- Returns
- the number of bytes that were successfully written, which may be any non-negative integer less than or equal to the size of the given view, including 0.
- Exceptions
-
◆ write() [1/2]
Write data to the end of an open file.
The writing position is advanced to the new end of the file.
- Parameters
-
- Exceptions
-
| File::Error | on failure to write to the file, or if not all of the data was written. |
◆ write() [2/2]
Write data to the end of an open file.
The writing position is advanced to the new end of the file.
- Parameters
-
- Exceptions
-
| File::Error | on failure to write to the file, or if not all of the data was written. |
◆ flush()
Synchronize with the underlying file to make sure that all buffered data that has been written so far is flushed into the actual file.
- Exceptions
-
The documentation for this class was generated from the following file: