From be09c60f5d30c287e8f52ab3b1d3c132678a1cd5 Mon Sep 17 00:00:00 2001
From: Gary Talent <gary@drinkingtea.net>
Date: Fri, 16 Apr 2021 21:19:10 -0500
Subject: [PATCH] [nostalgia/tools/pack] Replace cout and cerr with oxOut and
 oxErr

---
 src/nostalgia/tools/pack.cpp      | 7 +++----
 src/nostalgia/tools/pack/pack.cpp | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp
index 0b24f24d..f98a4a1d 100644
--- a/src/nostalgia/tools/pack.cpp
+++ b/src/nostalgia/tools/pack.cpp
@@ -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));
diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp
index a8146334..d3b34542 100644
--- a/src/nostalgia/tools/pack/pack.cpp
+++ b/src/nostalgia/tools/pack/pack.cpp
@@ -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});