ezEngine  Milestone 7
ezFileReader Class Reference

The default class to use to read data from a file, implements the ezStreamReaderBase interface. More...

#include <FileReader.h>

Inheritance diagram for ezFileReader:

Public Member Functions

 ezFileReader ()
 Constructor, does nothing.
 
 ~ezFileReader ()
 Destructor, closes the file, if it is still open (RAII).
 
ezResult Open (const char *szFile, ezUInt32 uiCacheSize=1024 *1024, bool bAllowFileEvents=true)
 Opens the given file for reading. Returns EZ_SUCCESS if the file could be opened. A cache is created to speed up small reads. More...
 
void Close ()
 Closes the file, if it is open.
 
virtual ezUInt64 ReadBytes (void *pReadBuffer, ezUInt64 uiBytesToRead) override
 Attempts to read the given number of bytes into the buffer. Returns the actual number of bytes read.
 
- Public Member Functions inherited from ezFileReaderBase
ezString128 GetFilePathAbsolute () const
 Returns the absolute path with which the file was opened (including the prefix of the data directory).
 
ezString128 GetFilePathRelative () const
 Returns the relative path of the file within its data directory (excluding the prefix of the data directory).
 
ezDataDirectoryTypeGetDataDirectory () const
 Returns the ezDataDirectoryType over which this file has been opened.
 
bool IsOpen () const
 Returns true, if the file is currently open.
 
ezUInt64 GetFileSize () const
 Returns the current total size of the file.
 
- Public Member Functions inherited from ezStreamReaderBase
 ezStreamReaderBase ()
 Constructor.
 
virtual ~ezStreamReaderBase ()
 Virtual destructor to ensure correct cleanup.
 
template<typename T >
ezResult ReadWordValue (T *pWordValue)
 Helper method to read a word value correctly (copes with potentially different endianess)
 
template<typename T >
ezResult ReadDWordValue (T *pDWordValue)
 Helper method to read a dword value correctly (copes with potentially different endianess)
 
template<typename T >
ezResult ReadQWordValue (T *pQWordValue)
 Helper method to read a qword value correctly (copes with potentially different endianess)
 
virtual ezUInt64 SkipBytes (ezUInt64 uiBytesToSkip)
 Helper method to skip a number of bytes (implementations of the stream reader may implement this more efficiently for example)
 

Private Member Functions

 EZ_DISALLOW_COPY_AND_ASSIGN (ezFileReader)
 

Private Attributes

ezUInt64 m_uiBytesCached
 
ezUInt64 m_uiCacheReadPosition
 
ezDynamicArray< ezUInt8 > m_Cache
 
bool m_bEOF
 

Additional Inherited Members

- Protected Member Functions inherited from ezFileReaderBase
ezDataDirectoryReaderGetFileReader (const char *szFile, bool bAllowFileEvents)
 
- Protected Attributes inherited from ezFileReaderBase
ezDataDirectoryReaderm_pDataDirReader
 

Detailed Description

The default class to use to read data from a file, implements the ezStreamReaderBase 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.

Member Function Documentation

ezResult ezFileReader::Open ( const char *  szFile,
ezUInt32  uiCacheSize = 1024 * 1024,
bool  bAllowFileEvents = true 
)

Opens the given file for reading. Returns EZ_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.


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