/
Doom3FileSystem.h
87 lines (65 loc) · 2.57 KB
/
Doom3FileSystem.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include "iarchive.h"
#include "ifilesystem.h"
namespace vfs
{
class AssetsList;
class Doom3FileSystem :
public VirtualFileSystem
{
private:
// Our ordered list of paths to search
SearchPaths _vfsSearchPaths;
std::list<std::string> _directories;
ExtensionSet _allowedExtensions;
std::set<std::string> _allowedExtensionsDir;
struct ArchiveDescriptor
{
std::string name;
IArchive::Ptr archive;
bool is_pakfile;
};
typedef std::list<ArchiveDescriptor> ArchiveList;
ArchiveList _archives;
typedef std::set<Observer*> ObserverList;
ObserverList _observers;
public:
void initialise(const SearchPaths& vfsSearchPaths, const ExtensionSet& allowedExtensions) override;
bool isInitialised() const override;
void shutdown() override;
const ExtensionSet& getArchiveExtensions() const override;
int getFileCount(const std::string& filename) override;
ArchiveFilePtr openFile(const std::string& filename) override;
ArchiveTextFilePtr openTextFile(const std::string& filename) override;
ArchiveFilePtr openFileInAbsolutePath(const std::string& filename) override;
ArchiveTextFilePtr openTextFileInAbsolutePath(const std::string& filename) override;
IArchive::Ptr openArchiveInAbsolutePath(const std::string& pathToArchive) override;
// Call the specified callback function for each file matching extension
// inside basedir.
void forEachFile(const std::string& basedir, const std::string& extension,
const VisitorFunc& visitorFunc, std::size_t depth) override;
void forEachFileInAbsolutePath(const std::string& path,
const std::string& extension,
const VisitorFunc& visitorFunc,
std::size_t depth = 1) override;
void forEachFileInArchive(const std::string& absoluteArchivePath,
const std::string& extension,
const VisitorFunc& visitorFunc,
std::size_t depth = 1) override;
std::string findFile(const std::string& name) override;
std::string findRoot(const std::string& name) override;
void addObserver(Observer& observer) override;
void removeObserver(Observer& observer) override;
const SearchPaths& getVfsSearchPaths() override;
FileInfo getFileInfo(const std::string& vfsRelativePath) override;
// RegisterableModule implementation
const std::string& getName() const override;
const StringSet& getDependencies() const override;
void initialiseModule(const IApplicationContext& ctx) override;
void shutdownModule() override;
private:
void initDirectory(const std::string& path);
void initPakFile(const std::string& filename);
std::shared_ptr<AssetsList> findAssetsList(const std::string& topLevelPath);
};
}