[nostalgia/tools/pack] Add missing error checking
This commit is contained in:
parent
74fe0c55cc
commit
74d1bb08fe
@ -21,7 +21,7 @@ using namespace ox;
|
||||
using namespace nostalgia::core;
|
||||
using namespace nostalgia::common;
|
||||
|
||||
ox::ValErr<std::vector<uint8_t>> loadFileBuff(std::string path, ::size_t *sizeOut = nullptr) {
|
||||
[[nodiscard]] ox::ValErr<std::vector<uint8_t>> loadFileBuff(std::string path, ::size_t *sizeOut = nullptr) {
|
||||
auto file = fopen(path.c_str(), "rb");
|
||||
if (file) {
|
||||
fseek(file, 0, SEEK_END);
|
||||
@ -39,7 +39,7 @@ ox::ValErr<std::vector<uint8_t>> loadFileBuff(std::string path, ::size_t *sizeOu
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error run(ClArgs args) {
|
||||
[[nodiscard]] ox::Error run(ClArgs args) {
|
||||
std::string argSrc = args.getString("src").c_str();
|
||||
std::string argDst = args.getString("dst").c_str();
|
||||
if (argSrc == "") {
|
||||
@ -51,7 +51,7 @@ ox::Error run(ClArgs args) {
|
||||
return OxError(1);
|
||||
}
|
||||
std::vector<uint8_t> buff(32 * ox::units::MB);
|
||||
ox::FileSystem32::format(buff.data(), buff.size());
|
||||
oxReturnError(ox::FileSystem32::format(buff.data(), buff.size()));
|
||||
ox::PassThroughFS src(argSrc.c_str());
|
||||
ox::FileSystem32 dst(ox::FileStore32(buff.data(), buff.size()));
|
||||
auto err = nostalgia::pack(&src, &dst);
|
||||
|
@ -27,20 +27,20 @@ namespace {
|
||||
* @return error
|
||||
* stub for now
|
||||
*/
|
||||
ox::Error pathToInode(std::vector<char>*) {
|
||||
[[nodiscard]] ox::Error pathToInode(std::vector<char>*) {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
// stub for now
|
||||
ox::Error toMetalClaw(std::vector<char>*) {
|
||||
[[nodiscard]] ox::Error toMetalClaw(std::vector<char>*) {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
// claw file transformations are broken out because path to inode
|
||||
// transformations need to be done after the copy to the new FS is complete
|
||||
ox::Error transformClaw(ox::FileSystem32 *dest, std::string path) {
|
||||
[[nodiscard]] ox::Error transformClaw(ox::FileSystem32 *dest, std::string path) {
|
||||
// copy
|
||||
dest->ls(path.c_str(), [dest, path](const char *name, ox::InodeId_t) {
|
||||
return dest->ls(path.c_str(), [dest, path](const char *name, ox::InodeId_t) {
|
||||
auto [stat, err] = dest->stat(path.c_str());
|
||||
oxReturnError(err);
|
||||
if (stat.fileType == ox::FileType_Directory) {
|
||||
@ -61,7 +61,6 @@ ox::Error transformClaw(ox::FileSystem32 *dest, std::string path) {
|
||||
}
|
||||
return OxError(0);
|
||||
});
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
[[nodiscard]] ox::Error verifyFile(ox::FileSystem32 *fs, const std::string &path, const std::vector<char> &expected) noexcept {
|
||||
@ -70,7 +69,7 @@ ox::Error transformClaw(ox::FileSystem32 *dest, std::string path) {
|
||||
return buff == expected ? 0 : OxError(1);
|
||||
}
|
||||
|
||||
ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, std::string path) {
|
||||
[[nodiscard]] ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, std::string path) {
|
||||
std::cout << "copying directory: " << path << '\n';
|
||||
// copy
|
||||
return src->ls(path.c_str(), [src, dest, path](const char *name, ox::InodeId_t) {
|
||||
@ -107,7 +106,7 @@ ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, std::string path)
|
||||
|
||||
}
|
||||
|
||||
ox::Error pack(ox::PassThroughFS *src, ox::FileSystem32 *dest, std::string path) {
|
||||
[[nodiscard]] ox::Error pack(ox::PassThroughFS *src, ox::FileSystem32 *dest, std::string path) {
|
||||
oxReturnError(copy(src, dest, path));
|
||||
oxReturnError(transformClaw(dest, path));
|
||||
return OxError(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user