![]() |
Plasma Engine
2.0
|
The default class to use to read data from a file, implements the plStreamReader interface. More...
#include <FileReader.h>
Public Member Functions | |
plFileReader ()=default | |
Constructor, does nothing. | |
~plFileReader () | |
Destructor, closes the file, if it is still open (RAII). | |
plResult | Open (plStringView sFile, plUInt32 uiCacheSize=1024 *64, plFileShareMode::Enum fileShareMode=plFileShareMode::Default, bool bAllowFileEvents=true) |
Opens the given file for reading. Returns PL_SUCCESS if the file could be opened. A cache is created to speed up small reads. | |
void | Close () |
Closes the file, if it is open. | |
virtual plUInt64 | ReadBytes (void *pReadBuffer, plUInt64 uiBytesToRead) override |
Attempts to read the given number of bytes into the buffer. Returns the actual number of bytes read. | |
virtual plUInt64 | SkipBytes (plUInt64 uiBytesToSkip) override |
Helper method to skip a number of bytes. Returns the actual number of bytes skipped. | |
bool | IsEOF () const |
Whether the end of the file was reached during reading. | |
![]() | |
plString128 | GetFilePathAbsolute () const |
Returns the absolute path with which the file was opened (including the prefix of the data directory). | |
plString128 | GetFilePathRelative () const |
Returns the relative path of the file within its data directory (excluding the prefix of the data directory). | |
plDataDirectoryType * | GetDataDirectory () const |
Returns the plDataDirectoryType over which this file has been opened. | |
bool | IsOpen () const |
Returns true, if the file is currently open. | |
plUInt64 | GetFileSize () const |
Returns the current total size of the file. | |
![]() | |
plStreamReader () | |
Constructor. | |
virtual | ~plStreamReader () |
Virtual destructor to ensure correct cleanup. | |
template<typename T > | |
plResult | ReadWordValue (T *pWordValue) |
Helper method to read a word value correctly (copes with potentially different endianess) | |
template<typename T > | |
plResult | ReadDWordValue (T *pDWordValue) |
Helper method to read a dword value correctly (copes with potentially different endianess) | |
template<typename T > | |
plResult | ReadQWordValue (T *pQWordValue) |
Helper method to read a qword value correctly (copes with potentially different endianess) | |
template<typename ArrayType , typename ValueType > | |
plResult | ReadArray (plArrayBase< ValueType, ArrayType > &inout_array) |
Reads an array of elements from the stream. | |
template<typename ValueType , plUInt16 uiSize, typename AllocatorWrapper > | |
plResult | ReadArray (plSmallArray< ValueType, uiSize, AllocatorWrapper > &ref_array) |
Reads a small array of elements from the stream. | |
template<typename ValueType , plUInt32 uiSize> | |
plResult | ReadArray (ValueType(&array)[uiSize]) |
Writes a C style fixed array. | |
template<typename KeyType , typename Comparer > | |
plResult | ReadSet (plSetBase< KeyType, Comparer > &inout_set) |
Reads a set. | |
template<typename KeyType , typename ValueType , typename Comparer > | |
plResult | ReadMap (plMapBase< KeyType, ValueType, Comparer > &inout_map) |
Reads a map. | |
template<typename KeyType , typename ValueType , typename Hasher > | |
plResult | ReadHashTable (plHashTableBase< KeyType, ValueType, Hasher > &inout_hashTable) |
Read a hash table (note that the entry order is not stable) | |
plResult | ReadString (plStringBuilder &ref_sBuilder) |
Reads a string into an plStringBuilder. | |
plResult | ReadString (plString &ref_sString) |
Reads a string into an plString. | |
PL_ALWAYS_INLINE plTypeVersion | ReadVersion (plTypeVersion expectedMaxVersion) |
Additional Inherited Members | |
![]() | |
plDataDirectoryReader * | GetFileReader (plStringView sFile, plFileShareMode::Enum FileShareMode, bool bAllowFileEvents) |
![]() | |
plDataDirectoryReader * | m_pDataDirReader |
The default class to use to read data from a file, implements the plStreamReader interface.
This file reader buffers reads up to a certain amount of bytes (configurable). It closes the file automatically once it goes out of scope.
|
inline |
Whether the end of the file was reached during reading.
plResult plFileReader::Open | ( | plStringView | sFile, |
plUInt32 | uiCacheSize = 1024 * 64, | ||
plFileShareMode::Enum | fileShareMode = plFileShareMode::Default, | ||
bool | bAllowFileEvents = true ) |
Opens the given file for reading. Returns PL_SUCCESS if the file could be opened. A cache is created to speed up small reads.
You should typically not disable bAllowFileEvents, unless you need to prevent recursive file events, which is only the case, if you are doing file accesses from within a File Event Handler.
|
overridevirtual |
Attempts to read the given number of bytes into the buffer. Returns the actual number of bytes read.
Implements plStreamReader.
|
overridevirtual |
Helper method to skip a number of bytes. Returns the actual number of bytes skipped.
Reimplemented from plStreamReader.