[nostalgia/core] Add PassthroughFS support to loadRomFs

This commit is contained in:
2020-02-11 21:34:55 -06:00
parent fffc66f18b
commit 90f94dbfc2
4 changed files with 23 additions and 32 deletions

View File

@@ -8,6 +8,7 @@
#include <ox/fs/fs.hpp>
#include <ox/std/units.hpp>
#include <nostalgia/core/core.hpp>
#include <nostalgia/world/world.hpp>
using namespace nostalgia;
@@ -28,29 +29,12 @@ ox::Error run(ox::FileSystem *fs) {
int main(int argc, const char **argv) {
if (argc > 1) {
ox::FileSystem *fs = nullptr;
char *rom = nullptr;
auto path = argv[1];
const auto lastDot = ox_lastIndexOf(path, '.');
const auto fsExt = lastDot != -1 ? path + lastDot : "";
if (ox_strcmp(fsExt, ".oxfs") == 0) {
rom = core::loadRom(path);
if (!rom) {
return 1;
}
fs = new (ox_alloca(sizeof(ox::FileStore32))) ox::FileSystem32(ox::FileStore32(rom, 32 * ox::units::MB));
} else {
#ifdef OX_HAS_PASSTHROUGHFS
fs = new (ox_alloca(sizeof(ox::PassThroughFS))) ox::PassThroughFS(path);
#else
return 2;
#endif
}
auto fs = core::loadRomFs(path);
auto err = run(fs);
oxAssert(err, "Something went wrong...");
fs->~FileSystem();
core::unloadRom(rom);
delete fs;
return err;
}
return 3;
return 1;
}