Skip to content

Commit

Permalink
smart chunking minimum size and disable
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Oct 14, 2022
1 parent 5ffd938 commit d9f6dbb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/rlib/ar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ auto Ar::process_iter_end(IO const& io, offset_cb cb, Entry const& top_entry, st
}

auto Ar::process(IO const& io, offset_cb cb, Entry const& top_entry) const -> void {
if (top_entry.nest && !no_wad && process_try_wad(io, cb, top_entry)) {
return;
}
if (top_entry.nest && !no_wpk && process_try_wpk(io, cb, top_entry)) {
return;
}
if (top_entry.nest && !no_zip && process_try_zip(io, cb, top_entry)) {
return;
if (top_entry.nest && min_nest && top_entry.size >= min_nest) {
if (!no_wad && process_try_wad(io, cb, top_entry)) {
return;
}
if (!no_wpk && process_try_wpk(io, cb, top_entry)) {
return;
}
if (!no_zip && process_try_zip(io, cb, top_entry)) {
return;
}
}
for (auto i = top_entry.offset, remain = top_entry.size; remain;) {
auto size = std::min(chunk_size, remain);
Expand Down
1 change: 1 addition & 0 deletions lib/rlib/ar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace rlib {
using offset_cb = function_ref<void(Entry)>;

std::size_t chunk_size;
std::size_t min_nest;
bool no_wad;
bool no_wpk;
bool no_zip;
Expand Down
6 changes: 6 additions & 0 deletions src/rman_make.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ struct Main {
program.add_argument("outbundle").help("Bundle file to write into.").required();
program.add_argument("rootfolder").help("Root folder to rebase from.").required();
program.add_argument("input").help("Files or folders for manifest.").remaining().required();

program.add_argument("--no-progress").help("Do not print progress.").default_value(false).implicit_value(true);
program.add_argument("--no-ar-wad").help("Disable wad spliting.").default_value(false).implicit_value(true);
program.add_argument("--no-ar-wpk").help("Disable wpk spliting.").default_value(false).implicit_value(true);
program.add_argument("--no-ar-zip").help("Disable zip spliting.").default_value(false).implicit_value(true);
program.add_argument("--min-ar-size")
.default_value(std::uint32_t{1})
.help("Smart chunking minimum size in killobytes (0 to disable).")
.action([](std::string const& value) -> std::uint32_t { return (std::uint32_t)std::stoul(value); });

program.add_argument("--chunk-size")
.default_value(std::uint32_t{256})
Expand Down Expand Up @@ -77,6 +82,7 @@ struct Main {

cli.ar = Ar{
.chunk_size = program.get<std::uint32_t>("--chunk-size") * KiB,
.min_nest = program.get<std::uint32_t>("--min-ar-size") * KiB,
.no_wad = program.get<bool>("--no-ar-wad"),
.no_wpk = program.get<bool>("--no-ar-wpk"),
.no_zip = program.get<bool>("--no-ar-zip"),
Expand Down

0 comments on commit d9f6dbb

Please sign in to comment.