diff --git a/src/nostalgia/tools/CMakeLists.txt b/src/nostalgia/tools/CMakeLists.txt index d7c2d897..a7bc0a21 100644 --- a/src/nostalgia/tools/CMakeLists.txt +++ b/src/nostalgia/tools/CMakeLists.txt @@ -3,6 +3,7 @@ add_executable(nost-pack pack.cpp) target_link_libraries( nost-pack OxClArgs + OxLogConn NostalgiaPack ) diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp index f035e393..d3ef5d3f 100644 --- a/src/nostalgia/tools/pack.cpp +++ b/src/nostalgia/tools/pack.cpp @@ -6,6 +6,7 @@ #include #include +#include #include @@ -42,7 +43,6 @@ static ox::Result readFileBuff(ox::CRStringView path) noexcept { } static ox::Error run(const ox::ClArgs &args) noexcept { - ox::trace::init(); const auto argSrc = args.getString("src", ""); const auto argRomBin = args.getString("rom-bin", ""); if (argSrc == "") { @@ -78,6 +78,16 @@ static ox::Error run(const ox::ClArgs &args) noexcept { } int main(int argc, const char **args) { + ox::trace::init(); +#ifdef DEBUG + ox::LoggerConn loggerConn; + const auto loggerErr = loggerConn.initConn("nost-pack"); + if (loggerErr) { + oxErrf("Could not connect to logger: {} ({}:{})\n", toStr(loggerErr), loggerErr.file, loggerErr.line); + } else { + ox::trace::setLogger(&loggerConn); + } +#endif const auto err = run(ox::ClArgs(argc, args)); oxAssert(err, "pack failed"); return static_cast(err); diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp index c82258a5..66d01774 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/nostalgia/tools/pack/pack.cpp @@ -32,7 +32,7 @@ static ox::Error pathToInode(ox::FileSystem *dest, ox::ModelObject *obj) noexcep case ox::FileAddressType::None: return {}; } - oxRequire(s, dest->stat(ox::StringView(path))); + oxRequire(s, dest->stat(path)); oxReturnError(o["type"].set(static_cast(ox::FileAddressType::Inode))); return data.set(2, s.inode); } @@ -121,7 +121,7 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, ox::CRStringVie continue; } oxOutf("reading {}\n", currentFile); - oxRequire(stat, src->stat(ox::StringView(currentFile))); + oxRequire(stat, src->stat(currentFile)); if (stat.fileType == ox::FileType::Directory) { oxReturnError(dest->mkdir(currentFile, true)); oxReturnError(copy(src, dest, currentFile + '/')); @@ -171,7 +171,7 @@ static ox::Error preloadDir(core::TypeStore *ts, ox::FileSystem *romFs, GbaPrelo oxRequire(fileList, romFs->ls(path)); for (const auto &name : fileList) { const auto filePath = ox::sfmt("{}{}", path, name); - oxRequire(stat, romFs->stat(ox::StringView(filePath))); + oxRequire(stat, romFs->stat(filePath)); if (stat.fileType == ox::FileType::Directory) { const auto dir = ox::sfmt("{}{}/", path, name); oxReturnError(preloadDir(ts, romFs, pl, dir));