28 std::filesystem::path
disk;
41 virtual std::vector<FileEntry>
List(std::string_view path) = 0;
46 virtual bool Move(std::string_view path, std::string_view toFolder, std::string& error) = 0;
50 virtual bool Rename(std::string_view path, std::string_view newName, std::string& error) = 0;
55 virtual bool Import(
const std::filesystem::path& source, std::string_view toFolder, std::string& error) = 0;
61 std::string
JoinPath(std::string_view folder, std::string_view name);
65 std::string_view
FileName(std::string_view path);
85 bool AddFile(std::string_view path, uint64_t size = 0);
87 std::vector<FileEntry>
List(std::string_view path)
override;
88 bool Move(std::string_view path, std::string_view toFolder, std::string& error)
override;
89 bool Rename(std::string_view path, std::string_view newName, std::string& error)
override;
90 bool Import(
const std::filesystem::path& source, std::string_view toFolder, std::string& error)
override;
91 uint64_t
Generation()
const override {
return m_generation; }
95 Node* Find(std::string_view path);
96 Node* AddPath(std::string_view path,
bool isFolder);
97 void Load(Node& folder);
99 std::unique_ptr<Node> m_root;
100 uint64_t m_generation = 0;
What a file view reads and changes.
Definition gui_file_system.h:35
virtual uint64_t Generation() const =0
Changes whenever what List returns may have: after a move, a rename or an import.
virtual bool Move(std::string_view path, std::string_view toFolder, std::string &error)=0
Moves the file or folder at path into the folder toFolder, keeping its name.
virtual bool Import(const std::filesystem::path &source, std::string_view toFolder, std::string &error)=0
Copies the file or folder at source, on the disk (a file dropped from another application),...
virtual bool Rename(std::string_view path, std::string_view newName, std::string &error)=0
Renames the file or folder at path in its folder.
virtual ~IFileSystem()=default
virtual std::vector< FileEntry > List(std::string_view path)=0
The entries in the folder at path, in no particular order; none when there's no such folder.
bool AddFolder(std::string_view path)
Adds the folder at path, and the folders on the way to it.
uint64_t Generation() const override
Changes whenever what List returns may have: after a move, a rename or an import.
Definition gui_file_system.h:91
~MemoryFileSystem() override
MemoryFileSystem(std::filesystem::path diskRoot)
A copy of the disk folder diskRoot, read as it's browsed.
bool Rename(std::string_view path, std::string_view newName, std::string &error) override
Renames the file or folder at path in its folder.
bool Import(const std::filesystem::path &source, std::string_view toFolder, std::string &error) override
Copies the file or folder at source, on the disk (a file dropped from another application),...
bool Move(std::string_view path, std::string_view toFolder, std::string &error) override
Moves the file or folder at path into the folder toFolder, keeping its name.
bool AddFile(std::string_view path, uint64_t size=0)
Adds a file at path (and the folders on the way to it), size bytes.
std::vector< FileEntry > List(std::string_view path) override
The entries in the folder at path, in no particular order; none when there's no such folder.
std::string JoinPath(std::string_view folder, std::string_view name)
folder and name as one path.
std::string_view ParentPath(std::string_view path)
The folder path is in; "" for an entry in the root (and for the root).
std::string_view FileName(std::string_view path)
The last name in path.
Definition gui_logging.h:24
A file or folder in a folder.
Definition gui_file_system.h:22
std::string name
Definition gui_file_system.h:23
std::filesystem::path disk
The file or folder on the disk it is, or is a copy of; empty for one that's only in the file system (...
Definition gui_file_system.h:28
uint64_t size
bytes; 0 for a folder
Definition gui_file_system.h:25
std::filesystem::file_time_type modified
when the file on the disk was last written
Definition gui_file_system.h:29
bool isFolder
Definition gui_file_system.h:24