Simplify coral::fs interface
This commit is contained in:
parent
13fffacd98
commit
be54ad3110
@ -144,41 +144,22 @@ export namespace coral {
|
||||
* Platform-generalized file system interface.
|
||||
*/
|
||||
struct fs {
|
||||
/**
|
||||
* Descriptor of the various rules that the file-system enforces over access to its files.
|
||||
*/
|
||||
struct access_rules {
|
||||
bool can_read;
|
||||
|
||||
bool can_write;
|
||||
};
|
||||
|
||||
enum class [[nodiscard]] walk_result {
|
||||
ok,
|
||||
not_implemented,
|
||||
access_denied,
|
||||
not_found,
|
||||
io_error,
|
||||
};
|
||||
using walker = closure<expected<optional<path>, io_error>()>;
|
||||
|
||||
virtual ~fs() {};
|
||||
|
||||
virtual walk_result walk_files(path const & target_path, closure<bool(path const &)> const & apply) {
|
||||
return walk_result::not_implemented;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the file-system for its global [access_rules], returning them.
|
||||
*
|
||||
*/
|
||||
virtual access_rules query_access() = 0;
|
||||
virtual void walk_files(path const & target_path, closure<void(walker const &)> const & then) {}
|
||||
|
||||
/**
|
||||
* Attempts to read the file in `file_path`, calling `then` if it was successfully opened for reading.
|
||||
* Attempts to read the file in `target_path`, calling `then` if it was successfully opened for reading.
|
||||
*/
|
||||
virtual void read_file(path const & target_path, closure<void(file_reader &)> const & then) {}
|
||||
|
||||
/**
|
||||
* Attempts to write the file in the file system located at `file_path`, calling `then` if it was successfully
|
||||
* Attempts to write the file in the file system located at `target_path`, calling `then` if it was successfully
|
||||
* opened for writing.
|
||||
*/
|
||||
virtual void write_file(path const & target_path, closure<void(file_writer &)> const & then) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user