[nostalgia/tools/pack] Cleanup

This commit is contained in:
Gary Talent 2019-07-22 23:17:08 -05:00
parent 8a562e1cc5
commit 84feeb8c1f
2 changed files with 7 additions and 4 deletions

View File

@ -74,7 +74,7 @@ namespace {
// copy // copy
return src->ls(path.c_str(), [src, dest, path](const char *name, ox::InodeId_t) { return src->ls(path.c_str(), [src, dest, path](const char *name, ox::InodeId_t) {
std::cout << "reading " << name << '\n'; std::cout << "reading " << name << '\n';
const auto currentFile = path + name; auto currentFile = path + name;
auto [stat, err] = src->stat((currentFile).c_str()); auto [stat, err] = src->stat((currentFile).c_str());
oxReturnError(err); oxReturnError(err);
if (stat.fileType == ox::FileType_Directory) { if (stat.fileType == ox::FileType_Directory) {
@ -83,10 +83,13 @@ namespace {
} else { } else {
std::vector<char> buff; std::vector<char> buff;
// do transforms // do transforms
if (endsWith(currentFile, ".png")) { constexpr std::string_view PngExt = ".png";
constexpr std::string_view GbagExt = ".ng";
if (endsWith(currentFile, PngExt)) {
// load file from full path and transform // load file from full path and transform
const auto fullPath = src->basePath() + currentFile; const auto fullPath = src->basePath() + currentFile;
buff = pngToGba(fullPath.c_str(), 0, 0); buff = pngToGba(fullPath.c_str(), 0, 0);
currentFile = currentFile.substr(0, currentFile.size() - PngExt.size()) + GbagExt.data();
if (!buff.size()) { if (!buff.size()) {
return OxError(1); return OxError(1);
} }