blob: ab93dff26eb2c3450c7479a75e697bc56403c952 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <zencore/zencore.h>
#include <zencore/iobuffer.h>
#include <zencore/refcount.h>
#include <zencore/thread.h>
#if ZEN_PLATFORM_WINDOWS
# include <zencore/windows.h>
#endif
ZEN_THIRD_PARTY_INCLUDES_START
#include <cxxopts.hpp>
ZEN_THIRD_PARTY_INCLUDES_END
#if ZEN_PLATFORM_WINDOWS
# include <atlfile.h>
#endif
#include <filesystem>
#include <list>
//////////////////////////////////////////////////////////////////////////
class FileBufferManager : public zen::RefCounted
{
public:
FileBufferManager(uint64_t BufferSize, uint64_t MaxBufferCount);
~FileBufferManager();
zen::IoBuffer AllocBuffer();
void ReturnBuffer(zen::IoBuffer Buffer);
private:
struct Impl;
Impl* m_Impl;
};
class InternalFile : public zen::RefCounted
{
public:
InternalFile();
~InternalFile();
void OpenRead(std::filesystem::path FileName);
void Read(void* Data, uint64_t Size, uint64_t Offset);
void OpenWrite(std::filesystem::path FileName, bool isCreate);
void Write(const void* Data, uint64_t Size, uint64_t Offset);
const void* MemoryMapFile();
size_t GetFileSize();
private:
#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
using CAtlFile = void*;
using CAtlFileMappingBase = void*;
#endif
CAtlFile m_File;
CAtlFileMappingBase m_Mmap;
void* m_Memory = nullptr;
};
|