From 3b9e00b1cb0f1fe97e032eaed03d27934ab3e15f Mon Sep 17 00:00:00 2001 From: kayomn Date: Thu, 2 Mar 2023 20:58:42 +0000 Subject: [PATCH] Add file info querying function to [coral::file_system] --- source/coral/files.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/source/coral/files.cpp b/source/coral/files.cpp index cde87cf..deef647 100755 --- a/source/coral/files.cpp +++ b/source/coral/files.cpp @@ -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 query_file(slice 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. */