From 8d2f3f2fa57b10876626ff3f2e7a2e1bb7febc5c Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 16 Oct 2022 07:40:00 +0200 Subject: [PATCH] tools/dumpnbt: Switch from using the validator to using the parser, update some strings --- src/tools/dumpnbt.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/tools/dumpnbt.cpp b/src/tools/dumpnbt.cpp index d28f098..c5a5c9d 100644 --- a/src/tools/dumpnbt.cpp +++ b/src/tools/dumpnbt.cpp @@ -25,6 +25,7 @@ #define EXIT_USAGE 2 #define EXIT_UNIMPLEMENTED 3 + int main(int argc, char* argv[]) { std::vector flags; flags.push_back(CLI::Flag('h', "help", "print help and exit")); @@ -32,9 +33,9 @@ int main(int argc, char* argv[]) { flags.push_back(CLI::Flag('x', "hexadecimal", "print numbers in hex format")); std::vector options; std::vector arguments; - arguments.push_back(CLI::Argument("FILE", "path of the file to work on")); + arguments.push_back(CLI::Argument("FILE", "path of the file to dump")); - CLI::ArgumentsParser cliParser = CLI::ArgumentsParser(argc, argv, flags, options, arguments, "Present NBT in human or machine readable formats - preliminary implementation."); + CLI::ArgumentsParser cliParser = CLI::ArgumentsParser(argc, argv, flags, options, arguments, "Present NBT in human or machine readable formats"); if (cliParser.getFlag("help").value){ std::cout << cliParser.getUsage() << std::endl; @@ -70,7 +71,7 @@ int main(int argc, char* argv[]) { std::ifstream fileStream; fileStream.open(cliParser.getArgument(0).value, std::ios::in | std::ios::binary | std::ios::ate); if (!fileStream.is_open()) { - std::cerr << argv[0] << ": File not found: " << cliParser.getArgument(0).value << std::endl; + std::cerr << argv[0] << ": Could not open file: " << cliParser.getArgument(0).value << std::endl; return EXIT_RUNTIME; } @@ -86,10 +87,8 @@ int main(int argc, char* argv[]) { } fileStream.close(); - bool isValidData = NBT::validateRawNBTData(data, fileSize); - if (isValidData) { - std::cerr << "Valid data." << std::endl; - } else { + ErrorOr> tags = NBT::deserialize(data, fileSize); + if (tags.isError) { std::cerr << "Invalid data." << std::endl; return EXIT_RUNTIME; }