Plasma Engine  2.0
Loading...
Searching...
No Matches
FileReader.h
1#pragma once
2
3#include <Foundation/Containers/DynamicArray.h>
4#include <Foundation/IO/FileSystem/Implementation/FileReaderWriterBase.h>
5#include <Foundation/IO/Stream.h>
6
11class PL_FOUNDATION_DLL plFileReader : public plFileReaderBase
12{
13 PL_DISALLOW_COPY_AND_ASSIGN(plFileReader);
14
15public:
18
19 = default;
20
22 ~plFileReader() { Close(); }
23
28 plResult Open(plStringView sFile, plUInt32 uiCacheSize = 1024 * 64, plFileShareMode::Enum fileShareMode = plFileShareMode::Default, bool bAllowFileEvents = true);
29
31 void Close();
32
34 virtual plUInt64 ReadBytes(void* pReadBuffer, plUInt64 uiBytesToRead) override;
35
37 virtual plUInt64 SkipBytes(plUInt64 uiBytesToSkip) override;
41 bool IsEOF() const { return m_bEOF; }
42
43private:
44 plUInt64 m_uiBytesCached = 0;
45 plUInt64 m_uiCacheReadPosition = 0;
47 bool m_bEOF = true;
48};
Definition DynamicArray.h:81
Definition FileReaderWriterBase.h:13
The default class to use to read data from a file, implements the plStreamReader interface.
Definition FileReader.h:12
bool IsEOF() const
Whether the end of the file was reached during reading.
Definition FileReader.h:41
~plFileReader()
Destructor, closes the file, if it is still open (RAII).
Definition FileReader.h:22
plFileReader()=default
Constructor, does nothing.
virtual plUInt64 SkipBytes(plUInt64 uiBytesToSkip)
Helper method to skip a number of bytes (implementations of the stream reader may implement this more...
Definition Stream.h:80
virtual plUInt64 ReadBytes(void *pReadBuffer, plUInt64 uiBytesToRead)=0
Reads a raw number of bytes into the read buffer, this is the only method which has to be implemented...
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Enum
Definition FileEnums.h:7
@ Default
Results in 'Exclusive' when requesting write access and 'SharedReads' when requesting read access....
Definition FileEnums.h:8
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54