Add file info querying function to [coral::file_system]

This commit is contained in:
kayomn 2023-03-02 20:58:42 +00:00
parent 530535b2a9
commit 3b9e00b1cb

View File

@ -61,11 +61,40 @@ export namespace coral {
* Platform-generalized file system interface.
*/
struct file_system {
/**
* Errors that may occur during a file system query operation.
*
* [query_error::unsupported] occurs when either part or all of the query operation is not supported on the
* given file system.
*
* [query_error::io_unavailable] is a general catch-all to report that an implementation-specific I/O error has
* occured and the operation could not proceed as a result.
*/
enum class query_error {
unsupported,
io_unavailable,
};
/**
* Various meta-information about a file in a file system.
*/
struct file_info {
u64 size;
};
virtual ~file_system() {};
/**
* Attempts to read the file in `path`, calling `then` if it was successfully opened for reading and passing the
* [file_reader] context along.
* Attempts to query a file in the file system located at `path`, returning a [file_info] describing it or a
* [query_error] if the operation failed.
*/
virtual expected<file_info, query_error> query_file(slice<char const> const & path) {
return query_error::unsupported;
}
/**
* Attempts to read a file in the file system located at `path`, calling `then` if it was successfully opened
* for reading and passing the [file_reader] context along.
*
* See [file_reader] for more information on how to read from the file.
*/