|
1 | | -/* $Id: tarcmd.cpp 111661 2025年11月12日 12:00:49Z knut.osmundsen@oracle.com $ */ |
| 1 | +/* $Id: tarcmd.cpp 111689 2025年11月12日 23:15:34Z knut.osmundsen@oracle.com $ */ |
2 | 2 | /** @file |
3 | 3 | * IPRT - A mini TAR Command. |
4 | 4 | */ |
@@ -128,8 +128,8 @@ typedef struct RTZIPTARCMDOPS |
128 | 128 | bool fRecursive; |
129 | 129 | /** The compressor/decompressor method to employ (0, z or j or J). */ |
130 | 130 | char chZipper; |
131 | | - /** The compression level, -1 for default. */ |
132 | | - int8_t iZipLevel; |
| 131 | + /** The compression level, 0 for default. */ |
| 132 | + uint8_t bZipLevel; |
133 | 133 |
|
134 | 134 | /** The owner to set. NULL if not applicable. |
135 | 135 | * Always resolved into uidOwner for extraction. */ |
@@ -606,15 +606,17 @@ static RTEXITCODE rtZipTarCmdOpenOutputArchive(PRTZIPTARCMDOPS pOpts, PRTVFSFSST |
606 | 606 |
|
607 | 607 | /* gunzip */ |
608 | 608 | case 'z': |
609 | | - rc = RTZipGzipCompressIoStream(hVfsIos, 0 /*fFlags*/, pOpts->iZipLevel < 0 ? 6 : pOpts->iZipLevel, &hVfsIosComp); |
| 609 | + rc = RTZipGzipCompressIoStream(hVfsIos, 0 /*fFlags*/, pOpts->bZipLevel == 0 ? 6 : RT_MIN(pOpts->bZipLevel, 9), |
| 610 | + &hVfsIosComp); |
610 | 611 | if (RT_FAILURE(rc)) |
611 | 612 | RTMsgError("Failed to open gzip decompressor: %Rrc", rc); |
612 | 613 | break; |
613 | 614 |
|
614 | 615 | #ifdef IPRT_WITH_LZMA |
615 | 616 | /* xz/lzma */ |
616 | 617 | case 'J': |
617 | | - rc = RTZipXzCompressIoStream(hVfsIos, 0 /*fFlags*/, pOpts->iZipLevel < 0 ? 6 : pOpts->iZipLevel, &hVfsIosComp); |
| 618 | + rc = RTZipXzCompressIoStream(hVfsIos, 0 /*fFlags*/, pOpts->bZipLevel == 0 ? 6 : RT_MIN(pOpts->bZipLevel, 9), |
| 619 | + &hVfsIosComp); |
618 | 620 | if (RT_FAILURE(rc)) |
619 | 621 | RTMsgError("Failed to open xz compressor: %Rrc", rc); |
620 | 622 | break; |
@@ -1846,7 +1848,7 @@ RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs) |
1846 | 1848 | { "--dir-mode-or-mask", RTZIPTARCMD_OPT_DIR_MODE_OR_MASK, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT }, |
1847 | 1849 | { "--read-ahead", RTZIPTARCMD_OPT_READ_AHEAD, RTGETOPT_REQ_NOTHING }, |
1848 | 1850 | { "--use-push-file", RTZIPTARCMD_OPT_USE_PUSH_FILE, RTGETOPT_REQ_NOTHING }, |
1849 | | - { "--compression-level", RTZIPTARCMD_OPT_COMPRESSION_LEVEL, RTGETOPT_REQ_INT8 }, |
| 1851 | + { "--compression-level", RTZIPTARCMD_OPT_COMPRESSION_LEVEL, RTGETOPT_REQ_UINT8 }, |
1850 | 1852 | }; |
1851 | 1853 |
|
1852 | 1854 | RTGETOPTSTATE GetState; |
@@ -2043,7 +2045,7 @@ RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs) |
2043 | 2045 | break; |
2044 | 2046 |
|
2045 | 2047 | case RTZIPTARCMD_OPT_COMPRESSION_LEVEL: |
2046 | | - Opts.iZipLevel = ValueUnion.i8; |
| 2048 | + Opts.bZipLevel = ValueUnion.u8; |
2047 | 2049 | break; |
2048 | 2050 |
|
2049 | 2051 | /* Standard bits. */ |
|
0 commit comments