Dump zones in zone_dump/zone_raw subfolder

This commit is contained in:
Jan 2021-03-22 13:23:24 +01:00
parent 6f6d25da4a
commit a18f001130
2 changed files with 23 additions and 14 deletions

View File

@ -40,7 +40,7 @@ const CommandLineOption* const OPTION_OUTPUT_FOLDER =
CommandLineOption::Builder::Create() CommandLineOption::Builder::Create()
.WithShortName("o") .WithShortName("o")
.WithLongName("output-folder") .WithLongName("output-folder")
.WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to ./%zoneName%") .WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to \"" + std::string(UnlinkerArgs::DEFAULT_OUTPUT_FOLDER) + "\"")
.WithParameter("outputFolderPath") .WithParameter("outputFolderPath")
.Build(); .Build();
@ -77,19 +77,20 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]
}; };
UnlinkerArgs::UnlinkerArgs() UnlinkerArgs::UnlinkerArgs()
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent<decltype(COMMAND_LINE_OPTIONS)>::value) : m_argument_parser(COMMAND_LINE_OPTIONS, std::extent<decltype(COMMAND_LINE_OPTIONS)>::value),
m_zone_pattern(R"(\?zone\?)"),
m_task(ProcessingTask::DUMP),
m_minimal_zone_def(false),
m_use_gdt(false),
m_verbose(false)
{ {
m_task = ProcessingTask::DUMP;
m_output_folder = "./%zoneName%";
m_verbose = false;
} }
void UnlinkerArgs::PrintUsage() void UnlinkerArgs::PrintUsage()
{ {
UsageInformation usage("unlinker.exe"); UsageInformation usage("Unlinker.exe");
for (auto commandLineOption : COMMAND_LINE_OPTIONS) for (const auto* commandLineOption : COMMAND_LINE_OPTIONS)
{ {
usage.AddCommandLineOption(commandLineOption); usage.AddCommandLineOption(commandLineOption);
} }
@ -109,9 +110,9 @@ void UnlinkerArgs::SetVerbose(const bool isVerbose)
bool UnlinkerArgs::SetImageDumpingMode() bool UnlinkerArgs::SetImageDumpingMode()
{ {
std::string specifiedValue = m_argument_parser.GetValueForOption(OPTION_IMAGE_FORMAT); auto specifiedValue = m_argument_parser.GetValueForOption(OPTION_IMAGE_FORMAT);
for (auto& c : specifiedValue) for (auto& c : specifiedValue)
c = tolower(c); c = static_cast<char>(tolower(c));
if (specifiedValue == "dds") if (specifiedValue == "dds")
{ {
@ -168,6 +169,8 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
// -o; --output-folder // -o; --output-folder
if (m_argument_parser.IsOptionSpecified(OPTION_OUTPUT_FOLDER)) if (m_argument_parser.IsOptionSpecified(OPTION_OUTPUT_FOLDER))
m_output_folder = m_argument_parser.GetValueForOption(OPTION_OUTPUT_FOLDER); m_output_folder = m_argument_parser.GetValueForOption(OPTION_OUTPUT_FOLDER);
else
m_output_folder = DEFAULT_OUTPUT_FOLDER;
// --search-path // --search-path
if (m_argument_parser.IsOptionSpecified(OPTION_SEARCH_PATH)) if (m_argument_parser.IsOptionSpecified(OPTION_SEARCH_PATH))
@ -195,5 +198,5 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
std::string UnlinkerArgs::GetOutputFolderPathForZone(Zone* zone) const std::string UnlinkerArgs::GetOutputFolderPathForZone(Zone* zone) const
{ {
return std::regex_replace(m_output_folder, std::regex("%zoneName%"), zone->m_name); return std::regex_replace(m_output_folder, m_zone_pattern, zone->m_name);
} }

View File

@ -1,13 +1,19 @@
#pragma once #pragma once
#include <regex>
#include <set>
#include <vector>
#include "Utils/Arguments/ArgumentParser.h" #include "Utils/Arguments/ArgumentParser.h"
#include "Zone/Zone.h" #include "Zone/Zone.h"
#include <vector>
#include <set>
class UnlinkerArgs class UnlinkerArgs
{ {
public:
static constexpr const char* DEFAULT_OUTPUT_FOLDER = "zone_dump/zone_raw/?zone?";
private:
ArgumentParser m_argument_parser; ArgumentParser m_argument_parser;
std::regex m_zone_pattern;
/** /**
* \brief Prints a command line usage help text for the Unlinker tool to stdout. * \brief Prints a command line usage help text for the Unlinker tool to stdout.