Plasma Engine  2.0
Loading...
Searching...
No Matches
MemoryMappedFile_NoImpl.h
1#include <Foundation/FoundationPCH.h>
2PL_FOUNDATION_INTERNAL_HEADER
3
4#include <Foundation/IO/MemoryMappedFile.h>
5#include <Foundation/Logging/Log.h>
6#include <Foundation/Strings/PathUtils.h>
7
9{
11 void* m_pMappedFilePtr = nullptr;
12 plUInt64 m_uiFileSize = 0;
13
15};
16
17plMemoryMappedFile::plMemoryMappedFile()
18{
19 m_pImpl = PL_DEFAULT_NEW(plMemoryMappedFileImpl);
20}
21
22plMemoryMappedFile::~plMemoryMappedFile()
23{
24 Close();
25}
26
28{
29 m_pImpl = PL_DEFAULT_NEW(plMemoryMappedFileImpl);
30}
31
33{
34 return m_pImpl->m_Mode;
35}
36
37const void* plMemoryMappedFile::GetReadPointer(plUInt64 uiOffset /*= 0*/, OffsetBase base /*= OffsetBase::Start*/) const
38{
39 PL_ASSERT_DEBUG(m_pImpl->m_Mode >= Mode::ReadOnly, "File must be opened with read access before accessing it for reading.");
40 return m_pImpl->m_pMappedFilePtr;
41}
42
43void* plMemoryMappedFile::GetWritePointer(plUInt64 uiOffset /*= 0*/, OffsetBase base /*= OffsetBase::Start*/)
44{
45 PL_ASSERT_DEBUG(m_pImpl->m_Mode >= Mode::ReadWrite, "File must be opened with read/write access before accessing it for writing.");
46 return m_pImpl->m_pMappedFilePtr;
47}
48
50{
51 return m_pImpl->m_uiFileSize;
52}
OffsetBase
The start point for interpreting byte offsets into the memory.
Definition MemoryMappedFile.h:25
void Close()
Removes the memory mapping. Outstanding modifications will be written back to disk at this point.
Definition MemoryMappedFile_NoImpl.h:27
const void * GetReadPointer(plUInt64 uiOffset=0, OffsetBase base=OffsetBase::Start) const
Returns a pointer for reading the mapped file. Asserts that the memory mapping was done successfully.
Definition MemoryMappedFile_NoImpl.h:37
Mode
Definition MemoryMappedFile.h:17
@ ReadOnly
File is mapped for read-only access.
@ None
Currently no file is mapped.
@ ReadWrite
File is mapped for read/write access.
void * GetWritePointer(plUInt64 uiOffset=0, OffsetBase base=OffsetBase::Start)
Returns a pointer for writing the mapped file. Asserts that the memory mapping was successful and the...
Definition MemoryMappedFile_NoImpl.h:43
Mode GetMode() const
Returns the mode with which the file was opened or None, if is currently not in use.
Definition MemoryMappedFile_NoImpl.h:32
plUInt64 GetFileSize() const
Returns the size (in bytes) of the memory mapping. Zero if no file is mapped at the moment.
Definition MemoryMappedFile_NoImpl.h:49
Definition MemoryMappedFile_NoImpl.h:9