aboutsummaryrefslogtreecommitdiff
path: root/primedev/core/filesystem/filesystem.h
blob: 4e2c18d9beb8fd2fb387c3d26c1c4a4f9879f63b (plain)
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
#pragma once
#include "core/sourceinterface.h"

// taken from ttf2sdk
typedef void* FileHandle_t;

struct VPKData;

enum SearchPathAdd_t
{
	PATH_ADD_TO_HEAD, // First path searched
	PATH_ADD_TO_TAIL, // Last path searched
};

class CSearchPath
{
public:
	unsigned char unknown[0x18];
	const char* debugPath;
};

class IFileSystem
{
public:
	struct VTable
	{
		void* unknown[10];
		void (*AddSearchPath)(IFileSystem* fileSystem, const char* pPath, const char* pathID, SearchPathAdd_t addType);
		void* unknown2[84];
		bool (*ReadFromCache)(IFileSystem* fileSystem, const char* path, void* result);
		void* unknown3[15];
		VPKData* (*MountVPK)(IFileSystem* fileSystem, const char* vpkPath);
	};

	struct VTable2
	{
		int (*Read)(IFileSystem::VTable2** fileSystem, void* pOutput, int size, FileHandle_t file);
		void* unknown[1];
		FileHandle_t (*Open)(
			IFileSystem::VTable2** fileSystem, const char* pFileName, const char* pOptions, const char* pathID, int64_t unknown);
		void (*Close)(IFileSystem* fileSystem, FileHandle_t file);
		long long (*Seek)(IFileSystem::VTable2** fileSystem, FileHandle_t file, long long offset, long long whence);
		void* unknown2[5];
		bool (*FileExists)(IFileSystem::VTable2** fileSystem, const char* pFileName, const char* pPathID);
	};

	VTable* m_vtable;
	VTable2* m_vtable2;
};

extern SourceInterface<IFileSystem>* g_pFilesystem;

std::string ReadVPKFile(const char* path);
std::string ReadVPKOriginalFile(const char* path);