ReXGlue SDK
Loading...
Searching...
No Matches
file_system.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <filesystem>
14#include <memory>
15#include <optional>
16#include <span>
17#include <string>
18#include <string_view>
19#include <vector>
20
22#include <rex/filesystem/file.h>
27#include <rex/memory/host.h>
28#include <rex/result.h>
29#include <rex/types.h>
30#include <rex/utility.h>
31
32namespace rex::filesystem {
33
34inline constexpr memory::Tag kFilesystem{7};
35
37class IFileSystem : public NonCopyable {
38 public:
39 virtual ~IFileSystem() = default;
40
47 [[nodiscard]] virtual Result<void> Mount(const MountEntry& entry) = 0;
48
54 [[nodiscard]] virtual Result<void> Unmount(std::string_view path) = 0;
55
56 [[nodiscard]] virtual std::vector<MountEntry> GetMounts() const = 0;
57
63 [[nodiscard]] virtual Result<void> Link(std::string_view link, std::string_view target) = 0;
64
70 [[nodiscard]] virtual Result<void> Unlink(std::string_view link) = 0;
71
76 [[nodiscard]] virtual std::optional<std::string> FindLink(std::string_view path) const = 0;
77
86 const std::filesystem::path& game_root, const std::filesystem::path& update_root,
87 MountFlags game_flags) = 0;
88
90 virtual void Clear() = 0;
91
100 [[nodiscard]] virtual Result<Opened> Open(std::string_view path, const OpenOptions& options) = 0;
101
108 [[nodiscard]] virtual Result<Opened> OpenRelative(IFile& root, std::string_view path,
109 const OpenOptions& options) = 0;
110
112 [[nodiscard]] virtual Result<FileStat> Stat(std::string_view path) = 0;
113
120 [[nodiscard]] virtual Result<std::unique_ptr<IDirectory>> List(std::string_view path,
121 std::string_view pattern) = 0;
122
128 [[nodiscard]] virtual Result<void> CreateDirectories(std::string_view path) = 0;
129
135 [[nodiscard]] virtual Result<void> Remove(std::string_view path) = 0;
136
145 [[nodiscard]] virtual Result<void> Rename(std::string_view from, std::string_view to,
146 bool replace_existing) = 0;
147
157 [[nodiscard]] virtual Result<void> Rename(IFile& file, std::string_view to, bool replace_existing,
158 IFile* root = nullptr) = 0;
159
161 [[nodiscard]] virtual Result<VolumeStat> GetVolume(std::string_view path) = 0;
162};
163
164} // namespace rex::filesystem
Definition file_system.h:37
virtual Result< void > Rename(IFile &file, std::string_view to, bool replace_existing, IFile *root=nullptr)=0
virtual Result< void > Unlink(std::string_view link)=0
virtual Result< void > Remove(std::string_view path)=0
virtual Result< void > CreateDirectories(std::string_view path)=0
virtual Result< Opened > OpenRelative(IFile &root, std::string_view path, const OpenOptions &options)=0
virtual Result< void > Mount(const MountEntry &entry)=0
virtual Result< void > Rename(std::string_view from, std::string_view to, bool replace_existing)=0
virtual Result< VolumeStat > GetVolume(std::string_view path)=0
virtual Result< void > ConfigureStandardMounts(const std::filesystem::path &game_root, const std::filesystem::path &update_root, MountFlags game_flags)=0
virtual Result< std::unique_ptr< IDirectory > > List(std::string_view path, std::string_view pattern)=0
virtual std::optional< std::string > FindLink(std::string_view path) const =0
virtual Result< void > Link(std::string_view link, std::string_view target)=0
virtual Result< void > Unmount(std::string_view path)=0
virtual Result< FileStat > Stat(std::string_view path)=0
virtual Result< Opened > Open(std::string_view path, const OpenOptions &options)=0
Definition file.h:27
MountFlags
Definition mount.h:38
Tag
Definition host.h:22
std::expected< T, Error > Result
Definition result.h:98
Definition mount.h:43
Definition file_open.h:59
Integer types, byte order wrappers and size literals.
Move only function, const propagating pointer and scope guard.