Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1fd5713

Browse files
IPRT/tar: Fixed handling of the compression level setting (missed init, but found we can use 0, so changed it to use 0 for default compression level instead of -1). bugref:10348
svn:sync-xref-src-repo-rev: r171281
1 parent 6c121e4 commit 1fd5713

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎src/VBox/Runtime/common/zip/tarcmd.cpp‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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 $ */
22
/** @file
33
* IPRT - A mini TAR Command.
44
*/
@@ -128,8 +128,8 @@ typedef struct RTZIPTARCMDOPS
128128
bool fRecursive;
129129
/** The compressor/decompressor method to employ (0, z or j or J). */
130130
char chZipper;
131-
/** The compression level, -1 for default. */
132-
int8_t iZipLevel;
131+
/** The compression level, 0 for default. */
132+
uint8_t bZipLevel;
133133

134134
/** The owner to set. NULL if not applicable.
135135
* Always resolved into uidOwner for extraction. */
@@ -606,15 +606,17 @@ static RTEXITCODE rtZipTarCmdOpenOutputArchive(PRTZIPTARCMDOPS pOpts, PRTVFSFSST
606606

607607
/* gunzip */
608608
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);
610611
if (RT_FAILURE(rc))
611612
RTMsgError("Failed to open gzip decompressor: %Rrc", rc);
612613
break;
613614

614615
#ifdef IPRT_WITH_LZMA
615616
/* xz/lzma */
616617
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);
618620
if (RT_FAILURE(rc))
619621
RTMsgError("Failed to open xz compressor: %Rrc", rc);
620622
break;
@@ -1846,7 +1848,7 @@ RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs)
18461848
{ "--dir-mode-or-mask", RTZIPTARCMD_OPT_DIR_MODE_OR_MASK, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT },
18471849
{ "--read-ahead", RTZIPTARCMD_OPT_READ_AHEAD, RTGETOPT_REQ_NOTHING },
18481850
{ "--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 },
18501852
};
18511853

18521854
RTGETOPTSTATE GetState;
@@ -2043,7 +2045,7 @@ RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs)
20432045
break;
20442046

20452047
case RTZIPTARCMD_OPT_COMPRESSION_LEVEL:
2046-
Opts.iZipLevel = ValueUnion.i8;
2048+
Opts.bZipLevel = ValueUnion.u8;
20472049
break;
20482050

20492051
/* Standard bits. */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /