Base interface for a writable file in a Filesystem.
More...
#include <GREM/core/system/File.hpp>
|
| | OutputFile () noexcept=default |
| | Default constructor.
|
| GREM_ALWAYS_INLINE | operator Writer () & |
| | Get a writer for the file.
|
| virtual size_t | tellp () const noexcept=0 |
| | Get the current writing position of the file.
|
| virtual void | seekp (size_t position)=0 |
| | Set the file writing position to an absolute offset from the beginning of the file.
|
| virtual void | skipp (ptrdiff_t offset)=0 |
| | Advance the file writing position by a relative offset, which may be negative in order to go backwards.
|
| virtual size_t | writeSome (Span< const byte > data)=0 |
| | Write data to the end of an open file from a buffer.
|
| 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.
|
| virtual void | flush ()=0 |
| | Synchronize with the underlying file to make sure that all buffered data that has been written so far is flushed into the actual 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.
|
| virtual void | close ()=0 |
| | 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.
|
| virtual bool | isOpen () const noexcept=0 |
| | Check if the file handle has an open file associated with it.
|
Base interface for a writable file in a Filesystem.
◆ OutputFile()
| grem::OutputFile::OutputFile |
( |
| ) |
|
|
defaultnoexcept |
◆ operator Writer()
Get a writer for the file.
- Returns
- a writer for the file.
◆ tellp()
| virtual size_t grem::OutputFile::tellp |
( |
| ) |
const |
|
nodiscardpure virtualnoexcept |
◆ seekp()
| virtual void grem::OutputFile::seekp |
( |
size_t | position | ) |
|
|
pure virtual |
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.
Implemented in grem::application::VirtualOutputFile, and grem::NativeOutputFile.
◆ skipp()
| virtual void grem::OutputFile::skipp |
( |
ptrdiff_t | offset | ) |
|
|
pure virtual |
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.
Implemented in grem::application::VirtualOutputFile, and grem::NativeOutputFile.
◆ writeSome()
| virtual size_t grem::OutputFile::writeSome |
( |
Span< const byte > | data | ) |
|
|
nodiscardpure virtual |
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
-
Implemented in grem::application::VirtualOutputFile, and grem::NativeOutputFile.
◆ write() [1/2]
| void grem::OutputFile::write |
( |
Span< const byte > | data | ) |
|
|
inline |
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 from a string to the end of an open file.
The writing position is advanced to the new end of the file.
- Parameters
-
| string | string containing the data to write. |
- Exceptions
-
| File::Error | on failure to write to the file, or if not all of the data was written. |
◆ flush()
| virtual void grem::OutputFile::flush |
( |
| ) |
|
|
pure virtual |
The documentation for this class was generated from the following file: