diff --git a/src/ox/fs/filesystem.cpp b/src/ox/fs/filesystem.cpp index 9e35d402d..bcac13e2f 100644 --- a/src/ox/fs/filesystem.cpp +++ b/src/ox/fs/filesystem.cpp @@ -15,13 +15,13 @@ FileSystem *createFileSystem(void *buff) { FileSystem *fs = nullptr; switch (type) { - case ox::fs::OxFS16: + case ox::fs::OxFS_16: fs = new FileSystem16(buff); break; - case ox::fs::OxFS32: + case ox::fs::OxFS_32: fs = new FileSystem32(buff); break; - case ox::fs::OxFS64: + case ox::fs::OxFS_64: fs = new FileSystem64(buff); break; } diff --git a/src/ox/fs/filesystem.hpp b/src/ox/fs/filesystem.hpp index 780439fd3..858a46df3 100644 --- a/src/ox/fs/filesystem.hpp +++ b/src/ox/fs/filesystem.hpp @@ -16,9 +16,9 @@ namespace fs { using namespace std; enum FsType { - OxFS16 = 1, - OxFS32 = 2, - OxFS64 = 3 + OxFS_16 = 1, + OxFS_32 = 2, + OxFS_64 = 3 }; struct FileStat { diff --git a/src/ox/fs/oxfstool.cpp b/src/ox/fs/oxfstool.cpp index 9d707edad..d306f12c6 100644 --- a/src/ox/fs/oxfstool.cpp +++ b/src/ox/fs/oxfstool.cpp @@ -50,13 +50,13 @@ int format(int argc, char **args) { // format switch (type) { case 16: - FileStore16::format(buff, size, ox::fs::OxFS16); + FileStore16::format(buff, size, ox::fs::OxFS_16); break; case 32: - FileStore32::format(buff, size, ox::fs::OxFS32); + FileStore32::format(buff, size, ox::fs::OxFS_32); break; case 64: - FileStore64::format(buff, size, ox::fs::OxFS64); + FileStore64::format(buff, size, ox::fs::OxFS_64); break; } createFileSystem(buff); @@ -88,16 +88,23 @@ int read(int argc, char **args) { ::size_t fsSize; ox::std::uint64_t fileSize; - auto fs = createFileSystem(loadFileBuff(fsPath, &fsSize)); + auto fsBuff = loadFileBuff(fsPath, &fsSize); + + if (fsBuff) { + auto fs = createFileSystem(fsBuff); - auto output = fs->read(inode, &fileSize); + auto output = fs->read(inode, &fileSize); - if (output) { - fwrite(output, fileSize, 1, stdout); - err = 0; + if (output) { + fwrite(output, fileSize, 1, stdout); + err = 0; + } + + delete fs; + delete fsBuff; + } else { + fprintf(stderr, "Could not open file: %s\n", fsPath); } - - delete fs; } return err; } @@ -110,7 +117,7 @@ int write(int argc, char **args) { auto srcPath = args[4]; ::size_t srcSize; - auto fsFile = fopen(fsPath, "rwb"); + auto fsFile = fopen(fsPath, "rb"); if (fsFile) { fseek(fsFile, 0, SEEK_END);