Export app::readable_file for API use

This commit is contained in:
kayomn 2023-02-20 16:12:29 +00:00
parent 685e09412b
commit 37b2586eaa
1 changed files with 70 additions and 68 deletions

View File

@ -11,7 +11,8 @@ import coral.math;
import oar;
struct file_reader : public coral::file_reader {
namespace app {
struct file_reader : public coral::file_reader {
enum class [[nodiscard]] close_result {
ok,
io_unavailable,
@ -94,7 +95,8 @@ struct file_reader : public coral::file_reader {
coral::fs * fs;
::SDL_RWops * rw_ops;
};
};
}
struct base_directory : public coral::fs {
base_directory() : directory_path{} {
@ -122,13 +124,13 @@ struct base_directory : public coral::fs {
void read_file(coral::path const & file_path, coral::callable<void(coral::file_reader &)> const & then) override {
if (this->directory_path.length == 0) return;
file_reader reader{this};
app::file_reader reader{this};
if (reader.open(file_path) != file_reader::open_result::ok) return;
if (reader.open(file_path) != app::file_reader::open_result::ok) return;
then(reader);
if (reader.close() != file_reader::close_result::ok) return;
if (reader.close() != app::file_reader::close_result::ok) return;
}
void write_file(coral::path const & file_path, coral::callable<void(coral::file_writer &)> const & then) override {
@ -165,13 +167,13 @@ struct user_directory : public coral::fs {
void read_file(coral::path const & file_path, coral::callable<void(coral::file_reader &)> const & then) override {
if (this->directory_path.length == 0) return;
file_reader reader{this};
app::file_reader reader{this};
if (reader.open(file_path) != file_reader::open_result::ok) return;
if (reader.open(file_path) != app::file_reader::open_result::ok) return;
then(reader);
if (reader.close() != file_reader::close_result::ok) return;
if (reader.close() != app::file_reader::close_result::ok) return;
}
void write_file(coral::path const & file_path, coral::callable<void(coral::file_writer &)> const & then) override {