kanzi::ReadOnlyDiskFile Class Reference

Implements the File interface for files residing on a disk. More...

#include <kanzi/core/platform/file/win32/read_only_disk_file.hpp>

Inheritance diagram for kanzi::ReadOnlyDiskFile:
kanzi::File kanzi::File kanzi::File

Public Member Functions

 ReadOnlyDiskFile (string_view filename)
 Constructor. More...
 
virtual ~ReadOnlyDiskFile () KZ_OVERRIDE
 
virtual void read (char *buffer, uint64_t count) KZ_OVERRIDE
 
virtual void write (const char *buffer, uint64_t count) KZ_OVERRIDE
 
virtual uint64_t size () const KZ_OVERRIDE
 
virtual uint64_t tell () const KZ_OVERRIDE
 
virtual void seek (SeekPosition position, int64_t offset) KZ_OVERRIDE
 Skips bytes in the underlying stream. More...
 
virtual const bytemap () KZ_OVERRIDE
 
 ReadOnlyDiskFile (string_view filename)
 Constructor. More...
 
virtual ~ReadOnlyDiskFile () KZ_OVERRIDE
 Destructor. More...
 
virtual void read (char *buffer, uint64_t count) KZ_OVERRIDE
 
virtual void write (const char *buffer, uint64_t count) KZ_OVERRIDE
 
virtual uint64_t size () const KZ_OVERRIDE
 
virtual uint64_t tell () const KZ_OVERRIDE
 
virtual void seek (SeekPosition position, int64_t offset) KZ_OVERRIDE
 
virtual const bytemap () KZ_OVERRIDE
 Creates a memory mapping of the disk file. More...
 
 ReadOnlyDiskFile (string_view filename)
 Constructor. More...
 
 ReadOnlyDiskFile (const char *filename)
 Constructor. More...
 
virtual ~ReadOnlyDiskFile () KZ_OVERRIDE
 Destructor. More...
 
virtual void read (char *buffer, uint64_t count) KZ_OVERRIDE
 
virtual void write (const char *buffer, uint64_t count) KZ_OVERRIDE
 
virtual uint64_t size () const KZ_OVERRIDE
 
virtual uint64_t tell () const KZ_OVERRIDE
 
virtual void seek (SeekPosition position, int64_t offset) KZ_OVERRIDE
 
virtual const bytemap () KZ_OVERRIDE
 Creates a memory mapping of the disk file. More...
 
- Public Member Functions inherited from kanzi::File
virtual ~File ()
 

Static Public Member Functions

static ReadOnlyDiskFileUniquePtr tryOpen (string_view filename)
 Factory function. More...
 
static ReadOnlyDiskFileUniquePtr tryOpen (string_view filename)
 Factory function. More...
 
static ReadOnlyDiskFileUniquePtr tryOpen (string_view filename)
 Factory function. More...
 

Protected Member Functions

 ReadOnlyDiskFile (KzsResourceFile *resourceFile)
 Constructor. More...
 
 ReadOnlyDiskFile (int fileDescriptor)
 Constructor. More...
 
 ReadOnlyDiskFile (HANDLE fileHandle)
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::File
 File ()
 

Protected Attributes

KzsResourceFilem_resourceFile
 Opaque handle to the disk file. More...
 
bytem_map
 Pointer to memory map. More...
 
int m_fileDescriptor
 Opaque handle to the disk file. More...
 
void * m_mapView
 Pointer to the memory map of the disk file. More...
 
vector< char > m_data
 Buffer for reading file contents if memory-mapping is not supported. More...
 
HANDLE m_fileHandle
 Opaque handle to the disk file. More...
 
HANDLE m_mapHandle
 Opaque handle to the memory map of the disk file. More...
 

Additional Inherited Members

- Public Types inherited from kanzi::File
enum  SeekPosition { SeekBegin, SeekCurrent }
 

Detailed Description

Implements the File interface for files residing on a disk.

Constructor & Destructor Documentation

kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( string_view  filename)
explicit

Constructor.

Parameters
filenameThe name (including path) of the disk file to handle. Throws runtime_error if file cannot be accessed.
virtual kanzi::ReadOnlyDiskFile::~ReadOnlyDiskFile ( )
virtual
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( KzsResourceFile resourceFile)
explicitprotected

Constructor.

Parameters
resourceFileA pointer to an open resource file.
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( string_view  filename)
explicit

Constructor.

Parameters
filenameThe name (including path) of the disk file to handle. Throws runtime_error if file cannot be accessed.
virtual kanzi::ReadOnlyDiskFile::~ReadOnlyDiskFile ( )
virtual

Destructor.

Closes the file handle.

kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( int  fileDescriptor)
explicitprotected

Constructor.

Parameters
fileDescriptorAn open disk file descriptor.
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( string_view  filename)
explicit

Constructor.

Parameters
filenameThe name (including path) of the disk file to handle. Throws runtime_error if file cannot be accessed.
kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( const char *  filename)
inlineexplicit

Constructor.

Parameters
filenameThe name (including path) of the disk file to handle. Throws runtime_error if file cannot be accessed.
virtual kanzi::ReadOnlyDiskFile::~ReadOnlyDiskFile ( )
virtual

Destructor.

Closes the file handle and unmaps the file as needed.

kanzi::ReadOnlyDiskFile::ReadOnlyDiskFile ( HANDLE  fileHandle)
explicitprotected

Constructor.

Parameters
fileHandleAn open disk file handle.

Member Function Documentation

static ReadOnlyDiskFileUniquePtr kanzi::ReadOnlyDiskFile::tryOpen ( string_view  filename)
static

Factory function.

Creates an object representing an open file handle to a disk file.

Parameters
filenameThe name (including path) of the disk file to handle.
Returns
Pointer to the object, or null when file cannot be accessed.
virtual void kanzi::ReadOnlyDiskFile::read ( char *  buffer,
uint64_t  count 
)
virtual

Implements kanzi::File.

virtual void kanzi::ReadOnlyDiskFile::write ( const char *  buffer,
uint64_t  count 
)
virtual

Implements kanzi::File.

virtual uint64_t kanzi::ReadOnlyDiskFile::size ( ) const
virtual

Implements kanzi::File.

virtual uint64_t kanzi::ReadOnlyDiskFile::tell ( ) const
virtual

Implements kanzi::File.

virtual void kanzi::ReadOnlyDiskFile::seek ( SeekPosition  position,
int64_t  offset 
)
virtual

Skips bytes in the underlying stream.

Parameters
offsetNumber of bytes to skip. Must be non-negative.

Implements kanzi::File.

virtual const byte* kanzi::ReadOnlyDiskFile::map ( )
virtual
Note
Some memory mapping operations on Android are limited to 32 bit.

Implements kanzi::File.

static ReadOnlyDiskFileUniquePtr kanzi::ReadOnlyDiskFile::tryOpen ( string_view  filename)
static

Factory function.

Creates an object representing an open file handle to a disk file.

Parameters
filenameThe name (including path) of the disk file to handle.
Returns
Pointer to the object, or null when file cannot be accessed.
virtual void kanzi::ReadOnlyDiskFile::read ( char *  buffer,
uint64_t  count 
)
virtual

Implements kanzi::File.

virtual void kanzi::ReadOnlyDiskFile::write ( const char *  buffer,
uint64_t  count 
)
virtual

Implements kanzi::File.

virtual uint64_t kanzi::ReadOnlyDiskFile::size ( ) const
virtual

Implements kanzi::File.

virtual uint64_t kanzi::ReadOnlyDiskFile::tell ( ) const
virtual

Implements kanzi::File.

virtual void kanzi::ReadOnlyDiskFile::seek ( SeekPosition  position,
int64_t  offset 
)
virtual

Implements kanzi::File.

virtual const byte* kanzi::ReadOnlyDiskFile::map ( )
virtual

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.

static ReadOnlyDiskFileUniquePtr kanzi::ReadOnlyDiskFile::tryOpen ( string_view  filename)
static

Factory function.

Creates an object representing an open file handle to a disk file.

Parameters
filenameThe name (including path) of the disk file to handle.
Returns
Pointer to the object, or null when file cannot be accessed.
virtual void kanzi::ReadOnlyDiskFile::read ( char *  buffer,
uint64_t  count 
)
virtual

Implements kanzi::File.

virtual void kanzi::ReadOnlyDiskFile::write ( const char *  buffer,
uint64_t  count 
)
virtual

Implements kanzi::File.

virtual uint64_t kanzi::ReadOnlyDiskFile::size ( ) const
virtual

Implements kanzi::File.

virtual uint64_t kanzi::ReadOnlyDiskFile::tell ( ) const
virtual

Implements kanzi::File.

virtual void kanzi::ReadOnlyDiskFile::seek ( SeekPosition  position,
int64_t  offset 
)
virtual

Implements kanzi::File.

virtual const byte* kanzi::ReadOnlyDiskFile::map ( )
virtual

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.

Member Data Documentation

KzsResourceFile* kanzi::ReadOnlyDiskFile::m_resourceFile
protected

Opaque handle to the disk file.

byte* kanzi::ReadOnlyDiskFile::m_map
protected

Pointer to memory map.

int kanzi::ReadOnlyDiskFile::m_fileDescriptor
protected

Opaque handle to the disk file.

void * kanzi::ReadOnlyDiskFile::m_mapView
protected

Pointer to the memory map of the disk file.

Pointer to the view of the memory map of the disk file.

vector<char> kanzi::ReadOnlyDiskFile::m_data
protected

Buffer for reading file contents if memory-mapping is not supported.

HANDLE kanzi::ReadOnlyDiskFile::m_fileHandle
protected

Opaque handle to the disk file.

HANDLE kanzi::ReadOnlyDiskFile::m_mapHandle
protected

Opaque handle to the memory map of the disk file.


The documentation for this class was generated from the following file: