From 14d6d92e87edd12aaf19253696f746e4bbe4c8c6 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Mon, 11 Oct 2010 00:46:48 -0400 Subject: [PATCH] Allow setting compression level --- write.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/write.c b/write.c index bf7dfbd..f51e2be 100644 --- a/write.c +++ b/write.c @@ -28,6 +28,7 @@ struct io_block_t { #define DEBUG 0 static bool gTar = true; +static uint32_t gPreset = LZMA_PRESET_DEFAULT; static size_t gNumEncodeThreads = 0; static pthread_t *gEncodeThreads = NULL; @@ -84,13 +85,17 @@ int main(int argc, char **argv) { debug("launch"); int ch; - while ((ch = getopt(argc, argv, "t")) != -1) { + while ((ch = getopt(argc, argv, "t0123456789")) != -1) { switch (ch) { case 't': gTar = false; break; default: - die("Unknown option"); + if (optopt >= '0' && optopt <= '9') { + gPreset = optopt - '0'; + } else { + die("Unknown option"); + } } } argc -= optind - 1; @@ -106,7 +111,7 @@ int main(int argc, char **argv) { // xz options lzma_options_lzma lzma_opts; - if (lzma_lzma_preset(&lzma_opts, LZMA_PRESET_DEFAULT)) + if (lzma_lzma_preset(&lzma_opts, gPreset)) die("Error setting lzma options"); gFilters[0] = (lzma_filter){ .id = LZMA_FILTER_LZMA2, .options = &lzma_opts };