Loading...
Searching...
No Matches
opennn::FileReader Class Reference
Thread-safe positional file reader (pread on POSIX, overlapped ReadFile on Windows). More...
#include <io_utilities.h>
Public Member Functions | |
| FileReader ()=default | |
| ~FileReader () | |
| FileReader (const FileReader &)=delete | |
| FileReader & | operator= (const FileReader &)=delete |
| FileReader (FileReader &&)=delete | |
| FileReader & | operator= (FileReader &&)=delete |
| void | open (const filesystem::path &path) |
| Opens the file at the given path for reading. | |
| void | close () |
| Closes the underlying file handle, if any. | |
| bool | is_open () const |
| Returns true while the underlying handle is open. | |
| void | read_at (void *buffer, size_t bytes, uint64_t offset) const |
| Reads bytes from a specific offset into the provided buffer (thread-safe). | |
| uint64_t | file_size () const |
| Returns the total size of the open file in bytes. | |
Detailed Description
Thread-safe positional file reader (pread on POSIX, overlapped ReadFile on Windows).
Constructor & Destructor Documentation
◆ FileReader() [1/3]
|
default |
◆ ~FileReader()
| opennn::FileReader::~FileReader | ( | ) |
◆ FileReader() [2/3]
|
delete |
◆ FileReader() [3/3]
|
delete |
Member Function Documentation
◆ close()
| void opennn::FileReader::close | ( | ) |
Closes the underlying file handle, if any.
◆ file_size()
|
nodiscard |
Returns the total size of the open file in bytes.
◆ is_open()
|
nodiscard |
Returns true while the underlying handle is open.
◆ open()
| void opennn::FileReader::open | ( | const filesystem::path & | path | ) |
Opens the file at the given path for reading.
◆ operator=() [1/2]
|
delete |
◆ operator=() [2/2]
|
delete |
◆ read_at()
| void opennn::FileReader::read_at | ( | void * | buffer, |
| size_t | bytes, | ||
| uint64_t | offset ) const |
Reads bytes from a specific offset into the provided buffer (thread-safe).
- Parameters
-
buffer Destination buffer (must hold at least bytes). bytes Number of bytes to read. offset Byte offset within the file to read from.