[nostalgia] Cleanup
This commit is contained in:
parent
0bcb78d3da
commit
f5ff700bf3
@ -16,6 +16,7 @@ add_executable(
|
||||
target_link_libraries(
|
||||
nostalgia-studio
|
||||
QDarkStyle
|
||||
OxClArgs
|
||||
NostalgiaCore-Studio
|
||||
NostalgiaStudio
|
||||
NostalgiaPack
|
||||
|
@ -2,6 +2,7 @@ add_executable(nost-pack pack.cpp)
|
||||
|
||||
target_link_libraries(
|
||||
nost-pack
|
||||
OxClArgs
|
||||
NostalgiaPack
|
||||
)
|
||||
|
||||
|
@ -51,7 +51,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
|
||||
}
|
||||
|
||||
int main(int argc, const char **args) {
|
||||
auto err = run(ox::ClArgs(argc, args));
|
||||
const auto err = run(ox::ClArgs(argc, args));
|
||||
oxAssert(err, "pack failed");
|
||||
return static_cast<int>(err);
|
||||
}
|
||||
|
@ -6,10 +6,8 @@ add_library(
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaPack PUBLIC
|
||||
OxClArgs
|
||||
OxClaw
|
||||
OxFS
|
||||
OxStd
|
||||
NostalgiaCommon
|
||||
NostalgiaCore
|
||||
)
|
||||
|
@ -19,15 +19,15 @@ namespace nostalgia {
|
||||
* @return error
|
||||
* stub for now
|
||||
*/
|
||||
static ox::Error pathToInode(ox::Vector<uint8_t>*) noexcept {
|
||||
static ox::Error pathToInode(ox::Buffer*) noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
// just strip header for now...
|
||||
static ox::Error toMetalClaw(ox::Vector<uint8_t> *buff) noexcept {
|
||||
static ox::Error toMetalClaw(ox::Buffer *buff) noexcept {
|
||||
oxRequire(mc, ox::stripClawHeader(ox::bit_cast<char*>(buff->data()), buff->size()));
|
||||
buff->resize(mc.size());
|
||||
ox_memcpy(buff->data(), mc.data(), mc.size());
|
||||
memcpy(buff->data(), mc.data(), mc.size());
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ static ox::Error transformClaw(ox::FileSystem *dest, const ox::String &path) noe
|
||||
// do transforms
|
||||
if (name.endsWith(".ng") || name.endsWith(".npal")) {
|
||||
// load file
|
||||
ox::Vector<uint8_t> buff(stat.size);
|
||||
ox::Buffer buff(stat.size);
|
||||
oxReturnError(dest->read(filePath.c_str(), buff.data(), buff.size()));
|
||||
// do transformations
|
||||
oxReturnError(pathToInode(&buff));
|
||||
@ -60,15 +60,15 @@ static ox::Error transformClaw(ox::FileSystem *dest, const ox::String &path) noe
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
static ox::Error verifyFile(ox::FileSystem *fs, const ox::String &path, const ox::Vector<uint8_t> &expected) noexcept {
|
||||
ox::Vector<uint8_t> buff(expected.size());
|
||||
static ox::Error verifyFile(ox::FileSystem *fs, const ox::String &path, const ox::Buffer &expected) noexcept {
|
||||
ox::Buffer buff(expected.size());
|
||||
oxReturnError(fs->read(path.c_str(), buff.data(), buff.size()));
|
||||
return OxError(buff == expected ? 0 : 1);
|
||||
}
|
||||
|
||||
struct VerificationPair {
|
||||
ox::String path;
|
||||
ox::Vector<uint8_t> buff;
|
||||
ox::Buffer buff;
|
||||
};
|
||||
|
||||
static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, const ox::String &path) noexcept {
|
||||
@ -87,15 +87,14 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, const ox::Strin
|
||||
oxReturnError(dest->mkdir(currentFile.c_str(), true));
|
||||
oxReturnError(copy(src, dest, currentFile + '/'));
|
||||
} else {
|
||||
ox::Vector<uint8_t> buff;
|
||||
ox::Buffer buff(stat.size);
|
||||
// load file
|
||||
buff.resize(stat.size);
|
||||
oxReturnError(src->read(currentFile.c_str(), buff.data(), buff.size()));
|
||||
// write file to dest
|
||||
oxOutf("writing {}\n", currentFile);
|
||||
oxReturnError(dest->write(currentFile.c_str(), buff.data(), buff.size()));
|
||||
oxReturnError(verifyFile(dest, currentFile, buff));
|
||||
verificationPairs.push_back({currentFile, buff});
|
||||
verificationPairs.emplace_back(currentFile, buff);
|
||||
}
|
||||
}
|
||||
// verify all at once in addition to right after the files are written
|
||||
|
Loading…
Reference in New Issue
Block a user