Changeset 33973 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Nov 11, 2010 11:10:10 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67635
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r33945 r33973 371 371 common/vfs/vfsbase.cpp \ 372 372 common/vfs/vfschain.cpp \ 373 common/vfs/vfsmisc.cpp \ 373 374 common/vfs/vfsstdfile.cpp \ 374 375 common/zip/zipgzip.cpp \ … … 479 480 nt/RTErrConvertFromNtStatus.cpp \ 480 481 r3/posix/env-posix.cpp \ 482 r3/win/RTHandleGetStandard-win.cpp \ 481 483 r3/win/RTSystemQueryOSInfo-win.cpp \ 482 484 r3/win/RTSystemQueryDmiString-win.cpp \ … … 537 539 r3/linux/RTSystemQueryDmiString-linux.cpp \ 538 540 r3/posix/RTFileQueryFsSizes-posix.cpp \ 541 r3/posix/RTHandleGetStandard-posix.cpp \ 539 542 r3/posix/RTMemProtect-posix.cpp \ 540 543 r3/posix/RTPathUserHome-posix.cpp \ … … 622 625 r3/os2/time-os2.cpp \ 623 626 r3/posix/RTFileQueryFsSizes-posix.cpp \ 627 r3/posix/RTHandleGetStandard-posix.cpp \ 624 628 r3/posix/RTMemProtect-posix.cpp \ 625 629 r3/posix/RTPathUserHome-posix.cpp \ … … 671 675 r3/darwin/time-darwin.cpp \ 672 676 r3/posix/RTFileQueryFsSizes-posix.cpp \ 677 r3/posix/RTHandleGetStandard-posix.cpp \ 673 678 r3/posix/RTMemProtect-posix.cpp \ 674 679 r3/posix/RTPathUserHome-posix.cpp \ … … 720 725 r3/freebsd/rtProcInitExePath-freebsd.cpp \ 721 726 r3/posix/RTFileQueryFsSizes-posix.cpp \ 727 r3/posix/RTHandleGetStandard-posix.cpp \ 722 728 r3/posix/RTMemProtect-posix.cpp \ 723 729 r3/posix/RTPathUserHome-posix.cpp \ … … 769 775 generic/RTThreadGetNativeState-generic.cpp \ 770 776 r3/posix/RTFileQueryFsSizes-posix.cpp \ 777 r3/posix/RTHandleGetStandard-posix.cpp \ 771 778 r3/posix/RTMemProtect-posix.cpp \ 772 779 r3/posix/RTPathUserHome-posix.cpp \ -
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r33948 r33973 1084 1084 1085 1085 1086 RTDECL(int) RTVfsNew IoStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTSEMRW hSemRW,1086 RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTSEMRW hSemRW, 1087 1087 PRTVFSFSSTREAM phVfsFss, void **ppvInstance) 1088 1088 { … … 1231 1231 1232 1232 RTVFSINTERNAL *pVfs = NULL; 1233 if (hVfs == NIL_RTVFS)1233 if (hVfs != NIL_RTVFS) 1234 1234 { 1235 1235 pVfs = hVfs; … … 1252 1252 pThis->Base.uMagic = RTVFSOBJ_MAGIC; 1253 1253 pThis->Base.pvThis = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT); 1254 pThis->Base.pOps = &pIoStreamOps->Obj; 1254 1255 pThis->Base.hSemRW = hSemRW != NIL_RTSEMRW ? hSemRW : pVfs ? pVfs->Base.hSemRW : NIL_RTSEMRW; 1255 1256 pThis->Base.hVfs = hVfs; … … 1299 1300 1300 1301 1301 RTDECL(int) 1302 RTDECL(int) RTVfsIoStrmQueryInfo(RTVFSIOSTREAM hVfsIos, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr) 1302 1303 { 1303 1304 RTVFSIOSTREAMINTERNAL *pThis = hVfsIos; … … 1308 1309 1309 1310 1310 RTDECL(int) RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, size_t *pcbRead)1311 RTDECL(int) RTVfsIoStrmRead(RTVFSIOSTREAM hVfsIos, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead) 1311 1312 { 1312 1313 AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER); … … 1316 1317 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1317 1318 AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE); 1319 AssertReturn(fBlocking || pcbRead, VERR_INVALID_PARAMETER); 1318 1320 1319 1321 RTSGSEG Seg = { pvBuf, cbToRead }; … … 1322 1324 1323 1325 rtVfsObjWriteLock(&pThis->Base); 1324 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, pcbRead == NULL /*fBlocking*/, pcbRead);1326 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbRead); 1325 1327 rtVfsObjWriteUnlock(&pThis->Base); 1326 1328 return rc; … … 1328 1330 1329 1331 1330 RTDECL(int) RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)1332 RTDECL(int) RTVfsIoStrmWrite(RTVFSIOSTREAM hVfsIos, const void *pvBuf, size_t cbToWrite, bool fBlocking, size_t *pcbWritten) 1331 1333 { 1332 1334 AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER); … … 1336 1338 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1337 1339 AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE); 1340 AssertReturn(fBlocking || pcbWritten, VERR_INVALID_PARAMETER); 1338 1341 1339 1342 RTSGSEG Seg = { (void *)pvBuf, cbToWrite }; … … 1342 1345 1343 1346 rtVfsObjWriteLock(&pThis->Base); 1344 int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, pcbWritten == NULL /*fBlocking*/, pcbWritten);1347 int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten); 1345 1348 rtVfsObjWriteUnlock(&pThis->Base); 1346 1349 return rc; … … 1348 1351 1349 1352 1350 RTDECL(int) 1353 RTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 1351 1354 { 1352 1355 AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER); … … 1366 1369 1367 1370 1368 RTDECL(int) 1371 RTDECL(int) RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 1369 1372 { 1370 1373 AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER); … … 1384 1387 1385 1388 1386 RTDECL(int) 1389 RTDECL(int) RTVfsIoStrmFlush(RTVFSIOSTREAM hVfsIos) 1387 1390 { 1388 1391 RTVFSIOSTREAMINTERNAL *pThis = hVfsIos; … … 1397 1400 1398 1401 1399 RTDECL(RTFOFF) 1400 1402 RTDECL(RTFOFF) RTVfsIoStrmPoll(RTVFSIOSTREAM hVfsIos, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr, 1403 uint32_t *pfRetEvents) 1401 1404 { 1402 1405 RTVFSIOSTREAMINTERNAL *pThis = hVfsIos; … … 1411 1414 1412 1415 1413 RTDECL(RTFOFF) 1416 RTDECL(RTFOFF) RTVfsIoStrmTell(RTVFSIOSTREAM hVfsIos) 1414 1417 { 1415 1418 RTVFSIOSTREAMINTERNAL *pThis = hVfsIos; … … 1427 1430 1428 1431 1429 RTDECL(int) 1432 RTDECL(int) RTVfsIoStrmSkip(RTVFSIOSTREAM hVfsIos, RTFOFF cb) 1430 1433 { 1431 1434 RTVFSIOSTREAMINTERNAL *pThis = hVfsIos; … … 1451 1454 size_t cbToRead = RT_MIN(cb, _64K); 1452 1455 rtVfsObjWriteLock(&pThis->Base); 1453 rc = RTVfsIoStrmRead(hVfsIos, pvBuf, cbToRead, NULL);1456 rc = RTVfsIoStrmRead(hVfsIos, pvBuf, cbToRead, true /*fBlocking*/, NULL); 1454 1457 rtVfsObjWriteUnlock(&pThis->Base); 1455 1458 if (RT_FAILURE(rc)) … … 1467 1470 1468 1471 1469 RTDECL(int) 1472 RTDECL(int) RTVfsIoStrmZeroFill(RTVFSIOSTREAM hVfsIos, RTFOFF cb) 1470 1473 { 1471 1474 RTVFSIOSTREAMINTERNAL *pThis = hVfsIos; … … 1490 1493 size_t cbToWrite = RT_MIN(cb, _64K); 1491 1494 rtVfsObjWriteLock(&pThis->Base); 1492 rc = RTVfsIoStrmWrite(hVfsIos, pvBuf, cbToWrite, NULL);1495 rc = RTVfsIoStrmWrite(hVfsIos, pvBuf, cbToWrite, true /*fBlocking*/, NULL); 1493 1496 rtVfsObjWriteUnlock(&pThis->Base); 1494 1497 if (RT_FAILURE(rc)) … … 1534 1537 1535 1538 RTVFSINTERNAL *pVfs = NULL; 1536 if (hVfs == NIL_RTVFS)1539 if (hVfs != NIL_RTVFS) 1537 1540 { 1538 1541 pVfs = hVfs; … … 1557 1560 pThis->Stream.pOps = &pFileOps->Stream; 1558 1561 pThis->Stream.Base.pvThis = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT); 1562 pThis->Stream.Base.pOps = &pFileOps->Stream.Obj; 1559 1563 pThis->Stream.Base.hSemRW = pVfs ? pVfs->Base.hSemRW : NIL_RTSEMRW; 1560 1564 pThis->Stream.Base.hVfs = hVfs; -
trunk/src/VBox/Runtime/common/vfs/vfschain.cpp
r33950 r33973 431 431 } 432 432 433 434 433 /* 435 434 * Ok, there should be an element here so add one to the return struct. … … 440 439 pElement->enmAction = enmAction; 441 440 442 /* First comes a type which is followed by a '('. */ 441 /* 442 * First up is the VFS object type followed by a parentheses. 443 */ 443 444 if (strncmp(pszSrc, "base", cch = 4) == 0) 444 445 pElement->enmTypeOut = RTVFSOBJTYPE_BASE; … … 495 496 } 496 497 497 /* Must end with a right par antheses. */498 /* Must end with a right parentheses. */ 498 499 if (*pszSrc != ')') 499 500 { … … 657 658 658 659 660 RTDECL(bool) RTVfsChainIsSpec(const char *pszSpec) 661 { 662 return pszSpec 663 && strcmp(pszSpec, RTVFSCHAIN_SPEC_PREFIX) == 0; 664 } 665 -
trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
r33903 r33973 446 446 } 447 447 448 449 RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint32_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos) 450 { 451 RTVFSFILE hVfsFile; 452 int rc = RTVfsFileFromRTFile(hFile, fOpen, fLeaveOpen, &hVfsFile); 453 if (RT_SUCCESS(rc)) 454 *phVfsIos = RTVfsFileToIoStream(hVfsFile); 455 return rc; 456 } 457 458 459 -
trunk/src/VBox/Runtime/common/zip/zipgzip.cpp
r33945 r33973 30 30 *******************************************************************************/ 31 31 #include "internal/iprt.h" 32 #include <iprt/ vfslowlevel.h>32 #include <iprt/zip.h> 33 33 34 34 #include <iprt/assert.h> … … 37 37 #include <iprt/poll.h> 38 38 #include <iprt/string.h> 39 #include <iprt/vfslowlevel.h> 40 39 41 #include <zlib.h> 40 42 … … 477 479 AssertPtrReturn(phVfsIosOut, VERR_INVALID_POINTER); 478 480 481 uint32_t cRefs = RTVfsIoStrmRetain(hVfsIosIn); 482 AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE); 483 479 484 /* 480 485 * Create the decompression I/O stream. … … 507 512 */ 508 513 size_t cbRead = 0; 509 rc = RTVfsIoStrmRead(pThis->hVfsIos, pThis->abBuffer, sizeof(RTZIPGZIPHDR), NULL /*pcbRead*/);514 rc = RTVfsIoStrmRead(pThis->hVfsIos, pThis->abBuffer, sizeof(RTZIPGZIPHDR), true /*fBlocking*/, NULL /*pcbRead*/); 510 515 if (RT_SUCCESS(rc)) 511 516 { … … 539 544 } 540 545 else 541 rc = rtZipGzipConvertErrFromZlib(pThis, rc); 546 rc = rtZipGzipConvertErrFromZlib(pThis, rc); /** @todo cleaning up in this situation is going to go wrong. */ 547 RTVfsIoStrmRelease(hVfsIos); 542 548 } 549 else 550 RTVfsIoStrmRelease(hVfsIosIn); 543 551 return rc; 544 552 } -
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r33678 r33973 572 572 RTLdrFlt_SOURCES = RTLdrFlt.cpp 573 573 574 # RTGzip - our gzip clone (for testing the gzip/gunzip streaming code) 575 PROGRAMS += RTGzip 576 RTGzip_TEMPLATE = VBOXR3TSTEXE 577 RTGzip_SOURCES = RTGzip.cpp 578 574 579 575 580 -
trunk/src/VBox/Runtime/testcase/RTGzip.cpp
r33911 r33973 31 31 #include <iprt/zip.h> 32 32 33 #include <iprt/buildconfig.h> 34 #include <iprt/file.h> 33 35 #include <iprt/getopt.h> 34 #include <iprt/init .h>36 #include <iprt/initterm.h> 35 37 #include <iprt/message.h> 38 #include <iprt/param.h> 39 #include <iprt/stream.h> 36 40 #include <iprt/string.h> 37 41 #include <iprt/vfs.h> 42 #include <iprt/zip.h> 38 43 39 44 … … 43 48 return false; 44 49 } 50 51 52 /** 53 * Pushes data from the input to the output I/O streams. 54 * 55 * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE. 56 * @param hVfsIn The input I/O stream. 57 * @param hVfsOut The input I/O stream. 58 */ 59 static RTEXITCODE gzipPush(RTVFSIOSTREAM hVfsIn, RTVFSIOSTREAM hVfsOut) 60 { 61 for (;;) 62 { 63 uint8_t abBuf[_64K]; 64 size_t cbRead; 65 int rc = RTVfsIoStrmRead(hVfsIn, abBuf, sizeof(abBuf), true /*fBlocking*/, &cbRead); 66 if (RT_FAILURE(rc)) 67 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsIoStrmRead failed: %Rrc", rc); 68 if (rc == VINF_EOF && cbRead == 0) 69 return RTEXITCODE_SUCCESS; 70 71 rc = RTVfsIoStrmWrite(hVfsOut, abBuf, cbRead, true /*fBlocking*/, NULL /*cbWritten*/); 72 if (RT_FAILURE(rc)) 73 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsIoStrmWrite failed: %Rrc", rc); 74 } 75 } 76 77 static RTEXITCODE gzipCompress(RTVFSIOSTREAM hVfsIn, RTVFSIOSTREAM hVfsOut) 78 { 79 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Compression is not yet implemented, sorry."); 80 } 81 82 83 static RTEXITCODE gzipCompressFile(const char *pszFile, bool fStdOut, bool fForce, PRTVFSIOSTREAM phVfsStdOut) 84 { 85 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Compression is not yet implemented, sorry."); 86 } 87 88 89 static RTEXITCODE gzipDecompress(RTVFSIOSTREAM hVfsIn, RTVFSIOSTREAM hVfsOut) 90 { 91 RTEXITCODE rcExit; 92 RTVFSIOSTREAM hVfsGunzip; 93 int rc = RTZipGzipDecompressIoStream(hVfsIn, 0 /*fFlags*/, &hVfsGunzip); 94 if (RT_SUCCESS(rc)) 95 { 96 rcExit = gzipPush(hVfsGunzip, hVfsOut); 97 RTVfsIoStrmRelease(hVfsGunzip); 98 } 99 else 100 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTZipGzipDecompressIoStream failed: %Rrc", rc); 101 return rcExit; 102 } 103 104 105 /** 106 * Handles a file on the command line. 107 * 108 * @returns exit code. 109 * @param pszFile The file to handle. 110 * @param fStdOut Whether to output to standard output or not. 111 * @param fForce Whether to output to or input from terminals. 112 * @param phVfsStdOut Pointer to the standard out handle. 113 * (input/output) 114 */ 115 static RTEXITCODE gzipDecompressFile(const char *pszFile, bool fStdOut, bool fForce, PRTVFSIOSTREAM phVfsStdOut) 116 { 117 /* 118 * Open the specified input file. 119 */ 120 const char *pszError; 121 RTVFSIOSTREAM hVfsIn; 122 int rc = RTVfsChainOpenIoStream(pszFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsIn, &pszError); 123 if (RT_FAILURE(rc)) 124 { 125 if (pszError && *pszError) 126 return RTMsgErrorExit(RTEXITCODE_FAILURE, 127 "RTVfsChainOpenIoStream failed with rc=%Rrc:\n" 128 " '%s'\n", 129 " %*s^\n", 130 rc, pszFile, pszError - pszFile, ""); 131 return RTMsgErrorExit(RTEXITCODE_FAILURE, 132 "RTVfsChainOpenIoStream failed with rc=%Rrc: '%s'", 133 rc, pszFile); 134 } 135 136 /* 137 * Output the output file. 138 */ 139 RTVFSIOSTREAM hVfsOut; 140 char szFinal[RTPATH_MAX]; 141 if (fStdOut) 142 { 143 if (*phVfsStdOut == NIL_RTVFSIOSTREAM) 144 { 145 rc = RTVfsIoStrmFromStdHandle(RTHANDLESTD_OUTPUT, 0 /*fOpen*/, true /*fLeaveOpen*/, phVfsStdOut); 146 if (RT_FAILURE(rc)) 147 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to set up standard out: %Rrc", rc); 148 } 149 hVfsOut = *phVfsStdOut; 150 szFinal[0] = '\0'; 151 } 152 else 153 { 154 rc = RTStrCopy(szFinal, sizeof(szFinal), pszFile); 155 /** @todo remove the extension? Or are we supposed 156 * to get the org name from the gzip stream? */ 157 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Decompressing to file is not implemented"); 158 } 159 160 /* 161 * Do the decompressing, then flush and close the output stream (unless 162 * it is stdout). 163 */ 164 RTEXITCODE rcExit = gzipDecompress(hVfsIn, hVfsOut); 165 RTVfsIoStrmRelease(hVfsIn); 166 rc = RTVfsIoStrmFlush(hVfsOut); 167 if (RT_FAILURE(rc)) 168 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to flush the output file: %Rrc", rc); 169 RTVfsIoStrmRelease(hVfsOut); 170 171 /* 172 * Remove the input file, if that's the desire of the caller, or 173 * remove the output file on decompression failure. 174 */ 175 if (!fStdOut) 176 { 177 if (rcExit == RTEXITCODE_SUCCESS) 178 { 179 rc = RTFileDelete(pszFile); 180 if (RT_FAILURE(rc)) 181 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTFileDelete failed with %rc: '%s'", rc, pszFile); 182 } 183 else 184 { 185 /* should we do this? */ 186 rc = RTFileDelete(szFinal); 187 if (RT_FAILURE(rc)) 188 RTMsgError("RTFileDelete failed with %rc: '%s'", rc, pszFile); 189 } 190 } 191 192 return rcExit; 193 } 194 195 196 static RTEXITCODE gzipTestFile(const char *pszFile, bool fForce) 197 { 198 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Testiong has not been implemented"); 199 } 200 201 202 static RTEXITCODE gzipListFile(const char *pszFile, bool fForce) 203 { 204 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Listing has not been implemented"); 205 } 206 45 207 46 208 int main(int argc, char **argv) … … 53 215 * Parse the command line. 54 216 */ 55 static const RTGETOPTDEF s_aOptions[] 217 static const RTGETOPTDEF s_aOptions[] = 56 218 { 57 219 { "--ascii", 'a', RTGETOPT_REQ_NOTHING }, … … 96 258 RTEXITCODE rcExit = RTEXITCODE_SUCCESS; 97 259 unsigned cProcessed = 0; 98 99 RTGETOPTSTAT GetState; 100 int rc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 101 RTGETOPTINIT_FLAGS_OPTS_FIRST); 260 RTVFSIOSTREAM hVfsStdOut= NIL_RTVFSIOSTREAM; 261 262 RTGETOPTSTATE GetState; 263 rc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 264 RTGETOPTINIT_FLAGS_OPTS_FIRST); 102 265 for (;;) 103 266 { … … 112 275 * input from stdin and write the output to stdout. 113 276 */ 114 if (cProcessed )277 if (cProcessed > 0) 115 278 return rcExit; 116 117 RTVFSIOSTREAM hVfsIn; 118 RTVFSIOSTREAM hVfsOut; 279 #if 0 280 rc = RTVfsFileFromRTFile(1, 281 RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE, 282 true /*fLeaveOpen*/, 283 &hVfsOut); 284 119 285 120 286 if (!fForce && isStdHandleATty(fDecompress ? 0 : 1)) … … 123 289 fDecompress ? "reading" : "writing", 124 290 fDecompress ? "from" : "to"); 291 #else 292 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "reading from standard input has not yet been implemented"); 293 #endif 125 294 return rcExit; 126 295 } … … 128 297 case VINF_GETOPT_NOT_OPTION: 129 298 { 130 RTVFSIOSTREAM hVfsSrc; 131 rc = RTVfsOpenIoStreamFromSpec(ValueUnion.psz, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsSrc); 299 if (!*pszSuff && !fStdOut) 300 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "The --suffix option specified an empty string"); 301 if (!fStdOut && RTVfsChainIsSpec(ValueUnion.psz)) 302 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Must use standard out with VFS chain specifications"); 303 304 RTEXITCODE rcExit2; 305 if (fList) 306 rcExit2 = gzipListFile(ValueUnion.psz, fForce); 307 else if (fTest) 308 rcExit2 = gzipTestFile(ValueUnion.psz, fForce); 309 else if (fDecompress) 310 rcExit2 = gzipDecompressFile(ValueUnion.psz, fStdOut, fForce, &hVfsStdOut); 311 else 312 rcExit2 = gzipCompressFile(ValueUnion.psz, fStdOut, fForce, &hVfsStdOut); 313 if (rcExit2 != RTEXITCODE_SUCCESS) 314 rcExit = rcExit2; 132 315 133 316 cProcessed++; 134 if (fDecompress)135 {136 }137 else138 {139 if (!*pszSuff && !fStdOut)140 return141 {142 }143 }144 317 break; 145 318 } … … 167 340 case '9': uLevel = 9; break; 168 341 342 case 'h': 343 RTPrintf("Usage: to be written\nOption dump:\n"); 344 for (unsigned i = 0; i < RT_ELEMENTS(s_aOptions); i++) 345 RTPrintf(" -%c,%s\n", s_aOptions[i].iShort, s_aOptions[i].pszLong); 346 return RTEXITCODE_SUCCESS; 347 348 case 'V': 349 RTPrintf("%sr%d\n", RTBldCfgVersion(), RTBldCfgRevision()); 350 return RTEXITCODE_SUCCESS; 351 169 352 default: 170 return RTGetOptPrintError( ch, &ValueUnion);353 return RTGetOptPrintError(rc, &ValueUnion); 171 354 } 172 355 }
Note:
See TracChangeset
for help on using the changeset viewer.