Implements the File interface for files residing on a disk.
More...
#include <kanzi/core/platform/file/win32/read_only_disk_file.hpp>
Implements the File interface for files residing on a disk.
◆ ReadOnlyDiskFile() [1/3]
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile |
( |
string_view | filename | ) |
|
|
explicit |
Constructor.
- Parameters
-
filename | The name (including path) of the disk file to handle. Throws runtime_error if file cannot be accessed. |
◆ ReadOnlyDiskFile() [2/3]
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile |
( |
const char * | filename | ) |
|
|
explicit |
Constructor.
- Parameters
-
filename | The name (including path) of the disk file to handle. Throws runtime_error if file cannot be accessed. |
◆ ~ReadOnlyDiskFile()
kanzi::ReadOnlyDiskFile::~ReadOnlyDiskFile |
( |
| ) |
|
|
override |
Destructor.
Closes the file handle and unmaps the file as needed.
◆ ReadOnlyDiskFile() [3/3]
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile |
( |
HANDLE | fileHandle | ) |
|
|
explicitprotected |
Constructor.
- Parameters
-
fileHandle | An open disk file handle. |
◆ tryOpen()
Factory function.
Creates an object representing an open file handle to a disk file.
- Parameters
-
filename | The name (including path) of the disk file to handle. |
- Returns
- Pointer to the object, or null when file cannot be accessed.
◆ read()
Reads data from a file.
The function starts reading at the current file position. When you call read(), it invalidates the pointer returned by map(). This function throws when its can't read count number of bytes from the File.
- Parameters
-
buffer | Buffer to which to read. The size of the buffer in bytes must be at least the size of the value you pass in the count parameter. |
count | Number of bytes to read. |
- See also
- write(), tell(), and map().
Implements kanzi::File.
◆ tryRead()
Tries to reads data from a file.
The function starts reading at the current file position. When you call tryRead(), it invalidates the pointer returned by map().
- Parameters
-
buffer | Buffer to which to read. The size of the buffer in bytes must be at least the size of the value you pass in the count parameter. |
count | Number of bytes to read. |
- See also
- write(), tell(), and map().
- Returns
- Returns the number of bytes read.
Implements kanzi::File.
◆ write()
Writes data to a file.
The function starts writing at the current file position. When you call write(), it invalidates the pointer returned by map().
- Parameters
-
buffer | Buffer from which to write. The size of the buffer in bytes must be at least the size of the value you pass in the count parameter. |
count | Number of bytes to write. |
- See also
- read(), tell(), and map().
Implements kanzi::File.
◆ size()
uintmax_t kanzi::ReadOnlyDiskFile::size |
( |
| ) |
const |
|
overridevirtual |
Gets the size of a file.
- Returns
- Returns the size of a file in bytes.
Implements kanzi::File.
◆ tell()
uintmax_t kanzi::ReadOnlyDiskFile::tell |
( |
| ) |
const |
|
overridevirtual |
◆ seek()
Sets the position in a file.
You can set the position as an offset to either the current position or the beginning of the file. When you call seek(), it invalidates the pointer returned by map().
- Parameters
-
position | Seek origin. |
offset | Offset in bytes from the seek origin. |
- See also
- SeekPosition and tell().
Implements kanzi::File.
◆ map()
const byte * kanzi::ReadOnlyDiskFile::map |
( |
| ) |
|
|
overridevirtual |
Creates a memory mapping of the disk file.
Does nothing if the disk file has already been memory mapped.
- Returns
- Pointer to the view of the memory map.
Implements kanzi::File.
◆ m_fileHandle
HANDLE kanzi::ReadOnlyDiskFile::m_fileHandle |
|
protected |
Opaque handle to the disk file.
◆ m_mapHandle
HANDLE kanzi::ReadOnlyDiskFile::m_mapHandle |
|
protected |
Opaque handle to the memory map of the disk file.
◆ m_mapView
void* kanzi::ReadOnlyDiskFile::m_mapView |
|
protected |
Pointer to the view of the memory map of the disk file.
The documentation for this class was generated from the following file: