Skip to content

Commit

Permalink
feat: add CLI option for (no-)mmap VFS I/O
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zao committed Dec 23, 2024
1 parent cc32d83 commit d52d2e2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bun_extract_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> tail_args;

command = argv[1];
Expand All @@ -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;
}
Expand Down Expand Up @@ -79,7 +86,7 @@ int main(int argc, char *argv[]) {

std::shared_ptr<GgpkVfs> 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
Expand Down

0 comments on commit d52d2e2

Please sign in to comment.