[UniqueHandleDeclaration2Snippet] More...
#include <File.h>
Public Types | |
| enum | SeekMode { SeekStart , SeekEnd , SeekCurrent } |
| How the offset to FileDescriptor::seek is defined. More... | |
Public Member Functions | |
| Result | openForWriteToDevNull () |
| ... [UniqueHandleDeclaration2Snippet] | |
| Result | openStdOutDuplicate () |
| Opens a duplicated file descriptor handle for reading from stdout. | |
| Result | openStdErrDuplicate () |
| Opens a duplicated file descriptor handle for reading from stderr. | |
| Result | openStdInDuplicate () |
| Opens a duplicated file descriptor handle for reading from stdin. | |
| Result | open (StringSpan path, FileOpen mode) |
| Opens a file descriptor handle from a file system path. | |
| Result | read (Span< char > data, Span< char > &actuallyRead, uint64_t offset) |
| Reads bytes at offset into user supplied span. | |
| Result | read (Span< uint8_t > data, Span< uint8_t > &actuallyRead, uint64_t offset) |
| Reads bytes at offset into user supplied span. | |
| Result | read (Span< char > data, Span< char > &actuallyRead) |
| Reads bytes from current position (FileDescriptor::seek) into user supplied Span. | |
| Result | read (Span< uint8_t > data, Span< uint8_t > &actuallyRead) |
| Reads bytes from current position (FileDescriptor::seek) into user supplied Span. | |
| template<typename T > | |
| Result | readUntilEOF (T &destination) |
| Reads into a given dynamic buffer until End of File (EOF) is signaled. | |
| Result | readUntilEOF (IGrowableBuffer &&buffer) |
| Reads into a given dynamic buffer until End of File (EOF) is signaled. | |
| Result | writeString (StringSpan data) |
| Writes a string to the file descriptor. | |
| Result | write (Span< const char > data, uint64_t offset) |
| Writes bytes at offset from start of the file descriptor. | |
| Result | write (Span< const uint8_t > data, uint64_t offset) |
| Writes bytes at offset from start of the file descriptor. | |
| Result | write (Span< const char > data) |
| Writes bytes from current position (FileDescriptor::seek) of the file descriptor. | |
| Result | write (Span< const uint8_t > data) |
| Writes bytes from current position (FileDescriptor::seek) of the file descriptor. | |
| Result | seek (SeekMode seekMode, int64_t offset) |
| Changes the current position in the file descriptor, if seekable. | |
| Result | currentPosition (size_t &position) const |
| Gets current descriptor position (if seekable) | |
| Result | sizeInBytes (size_t &sizeInBytes) const |
| Gets total file size in bytes (if seekable) | |
| UniqueHandle ()=default | |
| UniqueHandle (const UniqueHandle &v)=delete | |
| UniqueHandle (UniqueHandle &&v) | |
| UniqueHandle (const Handle &externalHandle) | |
Friends | |
| struct | File |
| struct | PipeDescriptor |
[UniqueHandleDeclaration2Snippet]
Open, read and write to/from a file descriptor (like a file or pipe).
How the offset to FileDescriptor::seek is defined.
| Enumerator | |
|---|---|
| SeekStart | Offset to FileDescriptor::seek is to be applied from start of descriptor. |
| SeekEnd | Offset to FileDescriptor::seek is to be applied (backwards) from end of descriptor. |
| SeekCurrent | Offset to FileDescriptor::seek is to be applied from current descriptor position. |
Gets current descriptor position (if seekable)
| position | (output) current position of file descriptor |
| Result SC::FileDescriptor::open | ( | StringSpan | path, |
| FileOpen | mode ) |
Opens a file descriptor handle from a file system path.
| path | The absolute path to file. It MUST be encoded in ASCII,UTF-8/16 on Windows, ASCII,UTF-8 on POSIX. |
| mode | The mode used to open file (read-only, write-append etc.) |
| Result SC::FileDescriptor::openForWriteToDevNull | ( | ) |
... [UniqueHandleDeclaration2Snippet]
Opens a file descriptor handle for writing to /dev/null or equivalent on current OS.
true if file has been opened successfully | Result SC::FileDescriptor::openStdErrDuplicate | ( | ) |
Opens a duplicated file descriptor handle for reading from stderr.
| Result SC::FileDescriptor::openStdInDuplicate | ( | ) |
Opens a duplicated file descriptor handle for reading from stdin.
| Result SC::FileDescriptor::openStdOutDuplicate | ( | ) |
Opens a duplicated file descriptor handle for reading from stdout.
Reads bytes from current position (FileDescriptor::seek) into user supplied Span.
| data | Span of bytes where data should be written to |
| actuallyRead | A sub-span of data of the actually read bytes. A zero sized span means EOF. |
Reads bytes at offset into user supplied span.
| data | Span of bytes where data should be written to |
| actuallyRead | A sub-span of data of the actually read bytes. A zero sized span means EOF. |
| offset | Offset from begin of the file descriptor where read should be started |
Reads bytes from current position (FileDescriptor::seek) into user supplied Span.
| data | Span of bytes where data should be written to |
| actuallyRead | A sub-span of data of the actually read bytes. A zero sized span means EOF. |
| Result SC::FileDescriptor::read | ( | Span< uint8_t > | data, |
| Span< uint8_t > & | actuallyRead, | ||
| uint64_t | offset ) |
Reads bytes at offset into user supplied span.
| data | Span of bytes where data should be written to |
| actuallyRead | A sub-span of data of the actually read bytes. A zero sized span means EOF. |
| offset | Offset from begin of the file descriptor where read should be started |
| Result SC::FileDescriptor::readUntilEOF | ( | IGrowableBuffer && | buffer | ) |
Reads into a given dynamic buffer until End of File (EOF) is signaled.
It works also for non-seekable file descriptors (stdout / in / err).
| buffer | A destination buffer to write to (it will be resized as needed) |
|
inline |
Reads into a given dynamic buffer until End of File (EOF) is signaled.
It works also for non-seekable file descriptors (stdout / in / err).
| T | Type of the destination buffer implementing IGrowableBuffer interface (String, SmallString, Buffer) |
| destination | A destination buffer to write to (it will be resized as needed) |
Changes the current position in the file descriptor, if seekable.
| seekMode | How the offset is defined (from start, end, current) |
| offset | An offset to be applied according to seekMode to this descriptor (can be negative) |
Gets total file size in bytes (if seekable)
| sizeInBytes | (output) total size of file |
Writes bytes from current position (FileDescriptor::seek) of the file descriptor.
| data | Span of bytes containing the data to write |
Writes bytes at offset from start of the file descriptor.
| data | Span of bytes containing the data to write |
| offset | Offset from begin of file descriptor to start writing |
Writes bytes from current position (FileDescriptor::seek) of the file descriptor.
| data | Span of bytes containing the data to write |
Writes bytes at offset from start of the file descriptor.
| data | Span of bytes containing the data to write |
| offset | Offset from begin of file descriptor to start writing |
| Result SC::FileDescriptor::writeString | ( | StringSpan | data | ) |
Writes a string to the file descriptor.
| data | The string data to write |