From d52d2e2b67034baf68435c4673864e7f5e5b0f22 Mon Sep 17 00:00:00 2001 From: Lars Viklund Date: Sun, 15 Dec 2024 14:02:26 +1300 Subject: [PATCH] feat: add CLI option for (no-)mmap VFS I/O Some platforms may be fine with memory-mapped I/O and shouldn't suffer because Windows is silly. The default is still file-based I/O and the user can be explicit with `--mmap` and `--no-mmap` to indicate their preference. --- bun_extract_file.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bun_extract_file.cpp b/bun_extract_file.cpp index 99c06c9..8745d8d 100644 --- a/bun_extract_file.cpp +++ b/bun_extract_file.cpp @@ -42,6 +42,7 @@ int main(int argc, char *argv[]) { std::filesystem::path ggpk_or_steam_dir; std::filesystem::path output_dir; bool use_regex = false; + bool use_mmap = false; std::vector tail_args; command = argv[1]; @@ -51,6 +52,12 @@ int main(int argc, char *argv[]) { if (argv[argi] == "--regex"sv) { use_regex = true; ++argi; + } else if (argv[argi] == "--mmap"sv) { + use_mmap = true; + ++argi; + } else if (argv[argi] == "--no-mmap"sv) { + use_mmap = false; + ++argi; } else { break; } @@ -79,7 +86,7 @@ int main(int argc, char *argv[]) { std::shared_ptr vfs; if (ggpk_or_steam_dir.extension() == ".ggpk") { - vfs = open_ggpk(ggpk_or_steam_dir); + vfs = open_ggpk(ggpk_or_steam_dir, use_mmap); } #if _WIN32