Unique handle to a writable file in the virtual Filesystem.
More...
#include <GREM/application/VirtualOutputFile.hpp>
|
| | VirtualOutputFile () noexcept=default |
| | Construct a closed file handle without an associated file.
|
| void | close () override |
| | 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.
|
| bool | isOpen () const noexcept override |
| | Check if the file handle has an open file associated with it.
|
| size_t | tellp () const noexcept override |
| | Get the current writing position of the file.
|
| void | seekp (size_t position) override |
| | Set the file writing position to an absolute offset from the beginning of the file.
|
| void | skipp (ptrdiff_t offset) override |
| | Advance the file writing position by a relative offset, which may be negative in order to go backwards.
|
| size_t | writeSome (Span< const byte > data) override |
| | Write data to the end of an open file from a buffer.
|
| void | flush () override |
| | Synchronize with the underlying file to make sure that all buffered data that has been written so far is flushed into the actual file.
|
| | OutputFile () noexcept=default |
| | Default constructor.
|
| GREM_ALWAYS_INLINE | operator Writer () & |
| | Get a writer for the file.
|
| void | write (Span< const byte > data) |
| | Write data to the end of an open file.
|
| void | write (StringView string) |
| | Write data from a string to the end of an open file.
|
| | File () noexcept=default |
| | Default constructor.
|
| virtual | ~File ()=default |
| | Virtual destructor.
|
| | File (const File &)=default |
| | Copy constructor.
|
| | File (File &&) noexcept=default |
| | Move constructor.
|
| File & | operator= (const File &)=default |
| | Copy assignment.
|
| File & | operator= (File &&) noexcept=default |
| | Move assignment.
|
| | operator bool () const noexcept |
| | Check if the file handle has an open file associated with it.
|
Unique handle to a writable file in the virtual Filesystem.
- Warning
- This file handle type may only be used during the lifetime of a Filesystem object, which initializes the relevant global context upon construction. Attempting to use the File API without an active Filesystem yields undefined behavior.
◆ VirtualOutputFile()
| grem::application::VirtualOutputFile::VirtualOutputFile |
( |
| ) |
|
|
defaultnoexcept |
Construct a closed file handle without an associated file.
◆ close()
| void grem::application::VirtualOutputFile::close |
( |
| ) |
|
|
overridevirtual |
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.
Implements grem::File.
◆ isOpen()
| bool grem::application::VirtualOutputFile::isOpen |
( |
| ) |
const |
|
inlinenodiscardoverridevirtualnoexcept |
Check if the file handle has an open file associated with it.
- Returns
- true if there is an associated open file, false otherwise.
Implements grem::File.
◆ tellp()
| size_t grem::application::VirtualOutputFile::tellp |
( |
| ) |
const |
|
nodiscardoverridevirtualnoexcept |
Get the current writing position of the file.
- Returns
- the current file writing position, or File::npos if it cannot be determined.
Implements grem::OutputFile.
◆ seekp()
| void grem::application::VirtualOutputFile::seekp |
( |
size_t | position | ) |
|
|
overridevirtual |
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.
Implements grem::OutputFile.
◆ skipp()
| void grem::application::VirtualOutputFile::skipp |
( |
ptrdiff_t | offset | ) |
|
|
overridevirtual |
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.
Implements grem::OutputFile.
◆ writeSome()
| size_t grem::application::VirtualOutputFile::writeSome |
( |
Span< const byte > | data | ) |
|
|
nodiscardoverridevirtual |
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
-
Implements grem::OutputFile.
◆ flush()
| void grem::application::VirtualOutputFile::flush |
( |
| ) |
|
|
overridevirtual |
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
-
Implements grem::OutputFile.
The documentation for this class was generated from the following file: