Skip to content

Commit c4e7a9f

Browse files
committed
rman-merge and rman-remake --with-prefix suport
1 parent 0ceaf9a commit c4e7a9f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/rman_merge.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct Main {
1919
std::vector<std::string> manifests = {};
2020
RFile::Match match = {};
2121
bool strip_chunks = 0;
22+
bool with_prefix = {};
2223
} cli = {};
2324
std::unique_ptr<RCache> cache = {};
2425

@@ -30,6 +31,10 @@ struct Main {
3031

3132
program.add_argument("--no-progress").help("Do not print progress.").default_value(false).implicit_value(true);
3233
program.add_argument("--strip-chunks").default_value(false).implicit_value(true);
34+
program.add_argument("--with-prefix")
35+
.help("Prefix file paths with manifest name")
36+
.default_value(false)
37+
.implicit_value(true);
3338

3439
// Cache options
3540
program.add_argument("--cache").help("Cache file path.").default_value(std::string{""});
@@ -86,6 +91,7 @@ struct Main {
8691
};
8792

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

9096
cli.match.langs = program.get<std::optional<std::regex>>("--filter-lang");
9197
cli.match.path = program.get<std::optional<std::regex>>("--filter-path");
@@ -105,7 +111,11 @@ struct Main {
105111

106112
std::cerr << "Processing input files ... " << std::endl;
107113
for (auto const& path : paths) {
114+
auto const name = path.filename().replace_extension("").generic_string() + '/';
108115
RFile::read_file(path, [&, this](RFile& rfile) {
116+
if (this->cli.with_prefix) {
117+
rfile.path.insert(rfile.path.begin(), name.begin(), name.end());
118+
}
109119
if (cli.match(rfile)) {
110120
process_file(rfile);
111121
writer(std::move(rfile));

src/rman_remake.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct Main {
118118
bool no_progress = {};
119119
bool append = {};
120120
bool strip_chunks = 0;
121+
bool with_prefix = {};
121122
std::size_t chunk_size = 0;
122123
std::int32_t level = 0;
123124
std::int32_t level_high_entropy = 0;
@@ -174,6 +175,10 @@ struct Main {
174175
.implicit_value(true);
175176
program.add_argument("--no-progress").help("Do not print progress.").default_value(false).implicit_value(true);
176177
program.add_argument("--strip-chunks").default_value(false).implicit_value(true);
178+
program.add_argument("--with-prefix")
179+
.help("Prefix file paths with manifest name")
180+
.default_value(false)
181+
.implicit_value(true);
177182

178183
program.add_argument("--no-ar")
179184
.help("Regex of disable smart chunkers, can be any of: " + Ar::PROCESSORS_LIST())
@@ -248,6 +253,7 @@ struct Main {
248253
cli.no_progress = program.get<bool>("--no-progress");
249254
cli.append = program.get<bool>("--append");
250255
cli.strip_chunks = program.get<bool>("--strip-chunks");
256+
cli.with_prefix = program.get<bool>("--with-prefix");
251257
cli.level = program.get<std::int32_t>("--level");
252258
cli.level_high_entropy = program.get<std::int32_t>("--level-high-entropy");
253259

@@ -278,8 +284,12 @@ struct Main {
278284

279285
std::cerr << "Processing input manifests ... " << std::endl;
280286
for (std::uint32_t index = manifests.size(); auto const& path : manifests) {
287+
auto const name = path.filename().replace_extension("").generic_string() + '/';
281288
std::cerr << "MANIFEST: " << path << std::endl;
282289
RFile::read_file(path, [&, this](RFile& ofile) {
290+
if (this->cli.with_prefix) {
291+
ofile.path.insert(ofile.path.begin(), name.begin(), name.end());
292+
}
283293
if (cli.match(ofile)) {
284294
auto nfile = add_file(ofile, outbundle, resume_file, index);
285295
writer(std::move(nfile));

0 commit comments

Comments
 (0)