载入中...
搜索中...
未找到
Filesystem.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <cstdlib>
6#include <cstring>
7#include <map>
8#include <memory>
9#include <mutex>
10#include <string>
11#include <vector>
12
15
16namespace eve {
17namespace filesystem {
18namespace physfs {
19
22public:
24 Filesystem();
26 ~Filesystem() override;
27
29 void init(const char* arg0) override;
30
32 void setFused(bool value) override;
34 bool isFused() const override;
35
37 bool setupWriteDirectory() override;
38
40 bool setIdentity(std::string ident, bool appendToPath = false) override;
42 std::string getIdentity() const override;
43
45 bool setSource(std::string source) override;
47 bool setSourceFromMemory(const void* data, size_t size) override;
48
50 std::string getSource() const override;
51
53 bool mount(std::string archive, std::string mountpoint, bool appendToPath = false) override;
55 bool mount(Data *data, std::string archivename, std::string mountpoint, bool appendToPath = false) override;
57 bool mountRealDirectory(std::string realDir, std::string mountpoint, bool appendToPath = false) override;
59 bool unmountRealDirectory(std::string realDir) override;
60
62 bool unmount(std::string archive) override;
64 bool unmount(Data *data) override;
65
67 filesystem::File *newFile(std::string filename) const override;
68
70 std::string getWorkingDirectory() override;
72 std::string getUserDirectory() override;
74 std::string getAppdataDirectory() override;
76 std::string getSaveDirectory() override;
78 std::string getSourceBaseDirectory() const override;
79
81 std::string getRealDirectory(std::string filename) const override;
82
84 bool getInfo(std::string filepath, Info &info) const override;
85
87 bool createDirectory(std::string dir) override;
88
90 bool remove(std::string file) override;
91
93 FileData *read(std::string filename, int64_t size = File::ALL) const override;
95 void write(std::string filename, const void *data, int64_t size) const override;
97 void append(std::string filename, const void *data, int64_t size) const override;
98
100 std::vector<std::string> getDirectoryItems(std::string dir) override;
101
103 void setSymlinksEnabled(bool enable) override;
105 bool areSymlinksEnabled() const override;
106
108 std::vector<std::string> &getRequirePath() override;
110 std::vector<std::string> &getCRequirePath() override;
111
113 void allowMountingForPath(const std::string &path) override;
114
116 bool watch(std::string path) override;
118 [[nodiscard]] eve::Result<void> watchRealDirectory(std::string realDir,
119 std::string reportPath) override;
121 bool unwatch(std::string path) override;
123 void unwatchAll() override;
125 int getWatchCount() const override;
127 std::string pollWatch() override;
129 std::string getLastWatchPath() const override;
131 std::string getLastWatchRealPath() const override;
132
133private:
134 bool resolveWatchTarget(const std::string &path, std::string &realDir, std::string &filterName,
135 std::string &reportPath);
136 FileWatch &watchers();
137
138 // Contains the current working directory (UTF8).
139 std::string cwd;
140
141 // %APPDATA% on Windows.
142 std::string appdata;
143
144 // This name will be used to create the folder
145 // in the appdata/userdata folder.
146 std::string save_identity;
147
148 // Full and relative paths of the game save folder.
149 // (Relative to the %APPDATA% folder, meaning that the
150 // relative string will look something like: ./LOVE/game)
151 std::string save_path_relative, save_path_full;
152
153 // The full path to the source of the game.
154 std::string game_source;
155
156 // Allow saving outside of the LOVE_APPDATA_FOLDER
157 // for release 'builds'
158 bool fused;
159 bool fusedSet;
160
161 // Search path for require
162 std::vector<std::string> requirePath;
163 std::vector<std::string> cRequirePath;
164
165 std::vector<std::string> allowedMountPaths;
166
167 std::map<std::string, Data*> mountedData;
168
169 std::unique_ptr<FileWatch> fileWatch_;
170 std::string lastWatchPath_;
171 std::string lastWatchRealPath_;
172
173 // Real directories mounted as virtual overlays (see mountRealDirectory).
174 std::vector<std::string> mountedRealDirs_;
175 std::mutex mountMu_;
176
177 // Owns the bytes backing a memory-mounted game archive (see setSourceFromMemory).
178 void* memoryArchive_ = nullptr;
179
180}; // Filesystem
181
182} // namespace physfs
183} // namespace filesystem
184} // namespace eve
double value
filesystem::File * file
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::string path
Definition PlayHost.cpp:110
float size
Definition TreeMesh.cpp:156
V3 dir
Definition TreeMesh.cpp:150
const UnitySourceAsset & source
Data public API.
Definition Data.h:8
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Data buffer paired with a filename (used for type identification).
Definition FileData.h:14
OS directory watch with a main-thread event queue. Desktop/mobile: backed by Poco::DirectoryWatcher (...
Definition FileWatch.h:26
A File interface, providing generic means of reading from and writing to files.
Definition File.h:14
EVENGINE_API_FOUNDATION public API.
Definition Filesystem.h:43
PhysFS 文件系统后端实现(挂载/解挂、读写、热重载)。
Definition Filesystem.h:21
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
glm::uvec4 info