From c4e7a9f4b9ff3265b3784961c50969b17a7450a3 Mon Sep 17 00:00:00 2001 From: moonshadow565 Date: Sat, 6 Apr 2024 21:26:06 +0200 Subject: [PATCH] rman-merge and rman-remake --with-prefix suport --- src/rman_merge.cpp | 10 ++++++++++ src/rman_remake.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/rman_merge.cpp b/src/rman_merge.cpp index 435849c..997ac21 100644 --- a/src/rman_merge.cpp +++ b/src/rman_merge.cpp @@ -19,6 +19,7 @@ struct Main { std::vector manifests = {}; RFile::Match match = {}; bool strip_chunks = 0; + bool with_prefix = {}; } cli = {}; std::unique_ptr cache = {}; @@ -30,6 +31,10 @@ struct Main { program.add_argument("--no-progress").help("Do not print progress.").default_value(false).implicit_value(true); program.add_argument("--strip-chunks").default_value(false).implicit_value(true); + program.add_argument("--with-prefix") + .help("Prefix file paths with manifest name") + .default_value(false) + .implicit_value(true); // Cache options program.add_argument("--cache").help("Cache file path.").default_value(std::string{""}); @@ -86,6 +91,7 @@ struct Main { }; cli.strip_chunks = program.get("--strip-chunks"); + cli.with_prefix = program.get("--with-prefix"); cli.match.langs = program.get>("--filter-lang"); cli.match.path = program.get>("--filter-path"); @@ -105,7 +111,11 @@ struct Main { std::cerr << "Processing input files ... " << std::endl; for (auto const& path : paths) { + auto const name = path.filename().replace_extension("").generic_string() + '/'; RFile::read_file(path, [&, this](RFile& rfile) { + if (this->cli.with_prefix) { + rfile.path.insert(rfile.path.begin(), name.begin(), name.end()); + } if (cli.match(rfile)) { process_file(rfile); writer(std::move(rfile)); diff --git a/src/rman_remake.cpp b/src/rman_remake.cpp index 8762d26..12f76c6 100644 --- a/src/rman_remake.cpp +++ b/src/rman_remake.cpp @@ -118,6 +118,7 @@ struct Main { bool no_progress = {}; bool append = {}; bool strip_chunks = 0; + bool with_prefix = {}; std::size_t chunk_size = 0; std::int32_t level = 0; std::int32_t level_high_entropy = 0; @@ -174,6 +175,10 @@ struct Main { .implicit_value(true); program.add_argument("--no-progress").help("Do not print progress.").default_value(false).implicit_value(true); program.add_argument("--strip-chunks").default_value(false).implicit_value(true); + program.add_argument("--with-prefix") + .help("Prefix file paths with manifest name") + .default_value(false) + .implicit_value(true); program.add_argument("--no-ar") .help("Regex of disable smart chunkers, can be any of: " + Ar::PROCESSORS_LIST()) @@ -248,6 +253,7 @@ struct Main { cli.no_progress = program.get("--no-progress"); cli.append = program.get("--append"); cli.strip_chunks = program.get("--strip-chunks"); + cli.with_prefix = program.get("--with-prefix"); cli.level = program.get("--level"); cli.level_high_entropy = program.get("--level-high-entropy"); @@ -278,8 +284,12 @@ struct Main { std::cerr << "Processing input manifests ... " << std::endl; for (std::uint32_t index = manifests.size(); auto const& path : manifests) { + auto const name = path.filename().replace_extension("").generic_string() + '/'; std::cerr << "MANIFEST: " << path << std::endl; RFile::read_file(path, [&, this](RFile& ofile) { + if (this->cli.with_prefix) { + ofile.path.insert(ofile.path.begin(), name.begin(), name.end()); + } if (cli.match(ofile)) { auto nfile = add_file(ofile, outbundle, resume_file, index); writer(std::move(nfile));