This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
MountedBuild.h
57 lines (44 loc) · 1.85 KB
/
MountedBuild.h
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
#pragma once
#include "containers/cancel_flag.h"
#include "filesystem/egfs.h"
#include "web/manifest/manifest.h"
#include "storage/storage.h"
#include <filesystem>
namespace fs = std::filesystem;
typedef std::function<void(uint32_t max)> ProgressSetMaxHandler;
typedef std::function<void()> ProgressIncrHandler;
typedef std::function<void()> ProgressFinishHandler;
struct ChunkMetadata {
std::shared_ptr<Chunk> Chunk;
bool Downloaded;
size_t FileSize;
uint16_t Flags;
};
typedef std::function<void(const ChunkMetadata& meta, bool lastUpdate)> QueryChunkCallback;
class MountedBuild {
public:
MountedBuild(Manifest manifest, fs::path mountDir, fs::path cachePath, uint32_t storageFlags, uint32_t memoryPoolCapacity);
~MountedBuild();
static bool SetupCacheDirectory(fs::path CacheDir);
void SetupGameDirectory(ProgressSetMaxHandler setMax, ProgressIncrHandler onProg, ProgressFinishHandler onFinish, cancel_flag& flag, uint32_t threadCount);
void PreloadAllChunks(ProgressSetMaxHandler setMax, ProgressIncrHandler onProg, ProgressFinishHandler onFinish, cancel_flag& flag, uint32_t threadCount);
void VerifyAllChunks(ProgressSetMaxHandler setMax, ProgressIncrHandler onProg, ProgressFinishHandler onFinish, cancel_flag& flag, uint32_t threadCount);
void PurgeUnusedChunks(cancel_flag& flag);
void QueryChunks(QueryChunkCallback onQuery, cancel_flag& flag, uint32_t threadCount);
uint32_t GetMissingChunkCount();
void LaunchGame(const char* additionalArgs);
const fs::path& GetCachePath() const {
return CacheDir;
}
const fs::path& GetMountPath() const {
return MountDir;
}
private:
void PreloadFile(File& File, uint32_t ThreadCount, cancel_flag& cancelFlag);
void FileRead(PVOID Handle, PVOID Buffer, UINT64 offset, ULONG length, ULONG* bytesRead);
fs::path MountDir;
fs::path CacheDir;
Manifest Build;
Storage StorageData;
std::unique_ptr<EGFS> Egfs;
};