[nostalgia/tools/pack] Replace cout and cerr with oxOut and oxErr

This commit is contained in:
Gary Talent 2021-04-16 21:19:10 -05:00
parent 86a38c7197
commit be09c60f5d
2 changed files with 6 additions and 8 deletions

View File

@ -7,7 +7,6 @@
*/
#include <fstream>
#include <iostream>
#include <vector>
#include <ox/clargs/clargs.hpp>
#include <ox/fs/fs.hpp>
@ -29,11 +28,11 @@ static ox::Error run(const ox::ClArgs &args) {
auto argSrc = args.getString("src", "");
auto argDst = args.getString("dst", "");
if (argSrc == "") {
std::cerr << "error: must specify a source directory\n";
oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n");
return OxError(1, "must specify a source directory");
}
if (argDst == "") {
std::cerr << "error: must specify a destination ROM file\n";
oxErr("\033[31;1;1merror:\033[0m must specify a destination ROM file\n");
return OxError(1, "must specify a destination ROM file");
}
ox::Vector<char> buff(32 * ox::units::MB);
@ -44,7 +43,7 @@ static ox::Error run(const ox::ClArgs &args) {
oxReturnError(dst.resize());
oxRequire(dstSize, dst.size());
std::cout << "new size: " << dstSize << '\n';
oxOutf("new size: {}\n", dstSize);
buff.resize(dstSize);
oxReturnError(writeFileBuff(argDst.c_str(), buff));

View File

@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <iostream>
#include <string_view>
#include <ox/claw/read.hpp>
@ -86,7 +85,7 @@ struct VerificationPair {
};
ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, ox::String path) {
std::cout << "copying directory: " << path.c_str() << '\n';
oxOutf("copying directory: {}\n", path);
ox::Vector<VerificationPair> verificationPairs;
// copy
oxReturnError(src->ls(path.c_str(), [&verificationPairs, src, dest, path](ox::String name, ox::InodeId_t) {
@ -94,7 +93,7 @@ ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, ox::String path)
if (currentFile == "/.nostalgia") {
return OxError(0);
}
std::cout << "reading " << name.c_str() << '\n';
oxOutf("reading {}\n", name);
auto [stat, err] = src->stat((currentFile).c_str());
oxReturnError(err);
if (stat.fileType == ox::FileType_Directory) {
@ -106,7 +105,7 @@ ox::Error copy(ox::PassThroughFS *src, ox::FileSystem32 *dest, ox::String path)
buff.resize(stat.size);
oxReturnError(src->read(currentFile.c_str(), buff.data(), buff.size()));
// write file to dest
std::cout << "writing " << currentFile.c_str() << '\n';
oxOutf("writing {}\n", currentFile);
oxReturnError(dest->write(currentFile.c_str(), buff.data(), buff.size()));
oxReturnError(verifyFile(dest, currentFile, buff));
verificationPairs.push_back({currentFile, buff});