TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::MemoryFileSystem Class Referencefinal

A file system kept in memory. More...

#include <gui_controls/gui_file_system.h>

Inheritance diagram for tachyon::MemoryFileSystem:

Public Member Functions

 MemoryFileSystem ()
 MemoryFileSystem (std::filesystem::path diskRoot)
 A copy of the disk folder diskRoot, read as it's browsed.
 ~MemoryFileSystem () override
bool AddFolder (std::string_view path)
 Adds the folder at path, and the folders on the way to it.
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.
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 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), into the folder toFolder under its own name.
uint64_t Generation () const override
 Changes whenever what List returns may have: after a move, a rename or an import.
Public Member Functions inherited from tachyon::IFileSystem
virtual ~IFileSystem ()=default

Detailed Description

A file system kept in memory.

Filled with AddFolder / AddFile, or a copy of a folder on the disk: each folder's entries are read from the disk the first time they're needed (listed, or looked into by a move). Moves, renames and imports change only the copy: an imported folder is read from the disk as it's browsed, like the rest.

Constructor & Destructor Documentation

◆ MemoryFileSystem() [1/2]

tachyon::MemoryFileSystem::MemoryFileSystem ( )

◆ MemoryFileSystem() [2/2]

tachyon::MemoryFileSystem::MemoryFileSystem ( std::filesystem::path diskRoot)
explicit

A copy of the disk folder diskRoot, read as it's browsed.

Entries that can't be read (no permission) are left out.

◆ ~MemoryFileSystem()

tachyon::MemoryFileSystem::~MemoryFileSystem ( )
override

Member Function Documentation

◆ AddFolder()

bool tachyon::MemoryFileSystem::AddFolder ( std::string_view path)

Adds the folder at path, and the folders on the way to it.

False when a file is in the way.

◆ AddFile()

bool tachyon::MemoryFileSystem::AddFile ( std::string_view path,
uint64_t size = 0 )

Adds a file at path (and the folders on the way to it), size bytes.

False when a file is in the way or something is already there.

◆ List()

std::vector< FileEntry > tachyon::MemoryFileSystem::List ( std::string_view path)
overridevirtual

The entries in the folder at path, in no particular order; none when there's no such folder.

Implements tachyon::IFileSystem.

◆ Move()

bool tachyon::MemoryFileSystem::Move ( std::string_view path,
std::string_view toFolder,
std::string & error )
overridevirtual

Moves the file or folder at path into the folder toFolder, keeping its name.

False, with error saying why, when it can't: there's no such file or folder, a folder would go into itself, or the name is taken there. Moving it to where it is changes nothing.

Implements tachyon::IFileSystem.

◆ Rename()

bool tachyon::MemoryFileSystem::Rename ( std::string_view path,
std::string_view newName,
std::string & error )
overridevirtual

Renames the file or folder at path in its folder.

False, with error saying why, when it can't: there's no such file or folder, the name is empty, has a '/' or '\', is "." or "..", or is taken.

Implements tachyon::IFileSystem.

◆ Import()

bool tachyon::MemoryFileSystem::Import ( const std::filesystem::path & source,
std::string_view toFolder,
std::string & error )
overridevirtual

Copies the file or folder at source, on the disk (a file dropped from another application), into the folder toFolder under its own name.

False, with error saying why, when it can't: there's no such file or folder on the disk, no folder toFolder, or the name is taken there.

Implements tachyon::IFileSystem.

◆ Generation()

uint64_t tachyon::MemoryFileSystem::Generation ( ) const
inlineoverridevirtual

Changes whenever what List returns may have: after a move, a rename or an import.

Implements tachyon::IFileSystem.


The documentation for this class was generated from the following file: