]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Added support for -k keep argument to minideflate. By default minideflate will now...
authorNathan Moinvaziri <nathan@nathanm.com>
Fri, 11 Mar 2022 22:53:47 +0000 (14:53 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 17 Mar 2023 20:27:56 +0000 (21:27 +0100)
test/minideflate.c

index a05429191e7f7c3f0c5e71dacc65d72f0da2cf5b..addbc02a521c9883b97b72f97adb6ea31577771f 100644 (file)
@@ -207,9 +207,10 @@ void inflate_params(FILE *fin, FILE *fout, int32_t read_buf_size, int32_t write_
 }
 
 void show_help(void) {
-    printf("Usage: minideflate [-c] [-f|-h|-R|-F] [-m level] [-r/-t size] [-s flush] [-w bits] [-0 to -9] [input file]\n\n" \
+    printf("Usage: minideflate [-c][-d][-k] [-f|-h|-R|-F] [-m level] [-r/-t size] [-s flush] [-w bits] [-0 to -9] [input file]\n\n" \
            "  -c : write to standard output\n" \
            "  -d : decompress\n" \
+           "  -k : keep input file\n" \
            "  -f : compress with Z_FILTERED\n" \
            "  -h : compress with Z_HUFFMAN_ONLY\n" \
            "  -R : compress with Z_RLE\n" \
@@ -236,6 +237,7 @@ int main(int argc, char **argv) {
     int32_t flush = Z_NO_FLUSH;
     uint8_t copyout = 0;
     uint8_t uncompr = 0;
+    uint8_t keep = 0;
     char out_file[320];
     FILE *fin = stdin;
     FILE *fout = stdout;
@@ -255,6 +257,8 @@ int main(int argc, char **argv) {
             copyout = 1;
         else if (strcmp(argv[i], "-d") == 0)
             uncompr = 1;
+        else if (strcmp(argv[i], "-k") == 0)
+            keep = 1;
         else if (strcmp(argv[i], "-f") == 0)
             strategy = Z_FILTERED;
         else if (strcmp(argv[i], "-F") == 0)
@@ -309,6 +313,9 @@ int main(int argc, char **argv) {
 
     if (fin != stdin) {
         fclose(fin);
+        if (!keep) {
+            unlink(argv[i]);
+        }
     }
     if (fout != stdout) {
         fclose(fout);