From d9f6dbb4dc39143237b8c1f60e2dd633ce8525bb Mon Sep 17 00:00:00 2001 From: moonshadow565 Date: Fri, 14 Oct 2022 07:53:46 +0200 Subject: [PATCH] smart chunking minimum size and disable --- lib/rlib/ar.cpp | 18 ++++++++++-------- lib/rlib/ar.hpp | 1 + src/rman_make.cpp | 6 ++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/rlib/ar.cpp b/lib/rlib/ar.cpp index 44ad373..500c7fb 100644 --- a/lib/rlib/ar.cpp +++ b/lib/rlib/ar.cpp @@ -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); diff --git a/lib/rlib/ar.hpp b/lib/rlib/ar.hpp index 1892b47..2108213 100644 --- a/lib/rlib/ar.hpp +++ b/lib/rlib/ar.hpp @@ -13,6 +13,7 @@ namespace rlib { using offset_cb = function_ref; std::size_t chunk_size; + std::size_t min_nest; bool no_wad; bool no_wpk; bool no_zip; diff --git a/src/rman_make.cpp b/src/rman_make.cpp index cacd900..a0e0f01 100644 --- a/src/rman_make.cpp +++ b/src/rman_make.cpp @@ -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}) @@ -77,6 +82,7 @@ struct Main { cli.ar = Ar{ .chunk_size = program.get("--chunk-size") * KiB, + .min_nest = program.get("--min-ar-size") * KiB, .no_wad = program.get("--no-ar-wad"), .no_wpk = program.get("--no-ar-wpk"), .no_zip = program.get("--no-ar-zip"),