46 std::string read_path;
47 std::shared_ptr<fs::FileHandle> read_file_handle;
48 std::string write_path;
49 std::shared_ptr<fs::FileHandle> write_file_handle;
50 fs::FileCompression comp;
52 virtual Result ValidateImpl(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp) = 0;
54 inline Result Validate(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp = fs::FileCompression::None) {
55 return this->ValidateImpl(path, file_handle, comp);
58 virtual Result ReadImpl(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp) = 0;
60 inline Result ReadFrom(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp = fs::FileCompression::None) {
61 NTR_R_TRY(this->ValidateImpl(path, file_handle, comp));
62 NTR_R_TRY(this->ReadImpl(path, file_handle, comp));
64 this->read_path = path;
65 this->read_file_handle = file_handle;
70 inline Result ReadCompressedFrom(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle) {
71 return this->ReadFrom(path, file_handle, fs::FileCompression::LZ77);
74 virtual Result WriteImpl(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp) = 0;
76 inline Result WriteTo(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle) {
77 NTR_R_TRY(this->WriteImpl(path, file_handle, this->comp));
79 this->write_path = path;
80 this->write_file_handle = file_handle;
84 inline Result WriteTo(std::shared_ptr<fs::FileHandle> file_handle) {
85 return this->WriteTo(this->read_path, file_handle);
94 std::string ext_fs_root_path;
98 inline std::string GetExternalFsPath(
const std::string &path) {
99 return this->ext_fs_root_path +
"/" + path;
102 inline std::string GetBasePath(
const std::string &ext_fs_path) {
103 return ext_fs_path.substr(this->ext_fs_root_path.length() + 1);
106 Result WriteImpl(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp)
override {
110 virtual Result SaveFileSystem() = 0;