Skip to content

Commit

Permalink
rman-merge and rman-remake --with-prefix suport
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Apr 6, 2024
1 parent 0ceaf9a commit c4e7a9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/rman_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct Main {
std::vector<std::string> manifests = {};
RFile::Match match = {};
bool strip_chunks = 0;
bool with_prefix = {};
} cli = {};
std::unique_ptr<RCache> cache = {};

Expand All @@ -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{""});
Expand Down Expand Up @@ -86,6 +91,7 @@ struct Main {
};

cli.strip_chunks = program.get<bool>("--strip-chunks");
cli.with_prefix = program.get<bool>("--with-prefix");

cli.match.langs = program.get<std::optional<std::regex>>("--filter-lang");
cli.match.path = program.get<std::optional<std::regex>>("--filter-path");
Expand All @@ -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));
Expand Down
10 changes: 10 additions & 0 deletions src/rman_remake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -248,6 +253,7 @@ struct Main {
cli.no_progress = program.get<bool>("--no-progress");
cli.append = program.get<bool>("--append");
cli.strip_chunks = program.get<bool>("--strip-chunks");
cli.with_prefix = program.get<bool>("--with-prefix");
cli.level = program.get<std::int32_t>("--level");
cli.level_high_entropy = program.get<std::int32_t>("--level-high-entropy");

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit c4e7a9f

Please sign in to comment.