Changeset 50146 in vbox
- Timestamp:
- Jan 21, 2014 5:32:30 PM (11 years ago)
- Location:
- trunk/src/VBox/Runtime/common/zip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/zip/gzipvfs.cpp
r48836 r50146 148 148 /** Set if we've reached the end of the zlib stream. */ 149 149 bool fEndOfStream; 150 /** The stream offset for pfnTell . */150 /** The stream offset for pfnTell, always the uncompressed data. */ 151 151 RTFOFF offStream; 152 152 /** The zlib stream. */ … … 377 377 378 378 Assert(pSgBuf->cSegs == 1); 379 AssertReturn(off == -1, VERR_INVALID_PARAMETER);380 379 if (!pThis->fDecompress) 381 380 return VERR_ACCESS_DENIED; 381 AssertReturn(off == -1 || off == pThis->offStream , VERR_INVALID_PARAMETER); 382 382 383 383 return rtZipGzip_ReadOneSeg(pThis, pSgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, fBlocking, pcbRead); … … 510 510 PRTZIPGZIPSTREAM pThis = (PRTZIPGZIPSTREAM)pvThis; 511 511 512 AssertReturn(off == -1, VERR_INVALID_PARAMETER);513 512 Assert(pSgBuf->cSegs == 1); NOREF(fBlocking); 514 515 513 if (pThis->fDecompress) 516 514 return VERR_ACCESS_DENIED; 517 518 /* 519 * Write out the intput buffer. Using a loop here because of potential 515 AssertReturn(off == -1 || off == pThis->offStream , VERR_INVALID_PARAMETER); 516 517 /* 518 * Write out the input buffer. Using a loop here because of potential 520 519 * integer type overflow since avail_in is uInt and cbSeg is size_t. 521 520 */ … … 541 540 } 542 541 542 pThis->offStream += cbWritten; 543 543 if (pcbWritten) 544 544 *pcbWritten = cbWritten; -
trunk/src/VBox/Runtime/common/zip/tarvfs.cpp
r50086 r50146 126 126 /** The current file position. */ 127 127 RTFOFF offFile; 128 /** The start position in the hVfsIos (for seekable hVfsIos). */ 129 RTFOFF offStart; 128 130 /** The number of padding bytes following the file. */ 129 131 uint32_t cbPadding; … … 1011 1013 1012 1014 /** 1013 * Reads one segment.1014 * 1015 * @returns IPRT status code. 1016 * @param pThis The instance data. 1017 * @param pvBuf Where to put the read bytes.1018 * @param cbToRead The number of bytes to read.1019 * @param fBlocking Whether to block or not. 1020 * @param pcbRead Where to store the number of bytes actually read.1021 */1022 static int rtZipTarFssIos_ReadOneSeg(PRTZIPTARIOSTREAM pThis, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead) 1023 { 1024 /*1025 * Fend of reads beyond the end of the stream here.1026 */1027 if ( pThis->fEndOfStream)1015 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 1016 */ 1017 static DECLCALLBACK(int) rtZipTarFssIos_Read(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 1018 { 1019 PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis; 1020 Assert(pSgBuf->cSegs == 1); 1021 1022 /* 1023 * Make offset into a real offset so it's possible to do random access 1024 * on TAR files that are seekable. Fend of reads beyond the end of the 1025 * stream. 1026 */ 1027 if (off < 0) 1028 off = pThis->offFile; 1029 if (off >= pThis->cbFile) 1028 1030 return pcbRead ? VINF_EOF : VERR_EOF; 1029 1031 1032 1030 1033 Assert(pThis->cbFile >= pThis->offFile); 1031 uint64_t cbLeft = (uint64_t)(pThis->cbFile - pThis->offFile); 1034 uint64_t cbLeft = (uint64_t)(pThis->cbFile - pThis->offFile); 1035 size_t cbToRead = pSgBuf->paSegs[0].cbSeg; 1032 1036 if (cbToRead > cbLeft) 1033 1037 { … … 1043 1047 if (!pcbRead) 1044 1048 pcbRead = &cbReadStack; 1045 int rc = RTVfsIoStrmRead (pThis->hVfsIos, pvBuf, cbToRead, fBlocking, pcbRead);1046 pThis->offFile +=*pcbRead;1049 int rc = RTVfsIoStrmReadAt(pThis->hVfsIos, pThis->offStart + off, pSgBuf->paSegs[0].pvSeg, cbToRead, fBlocking, pcbRead); 1050 pThis->offFile = off + *pcbRead; 1047 1051 if (pThis->offFile >= pThis->cbFile) 1048 1052 { … … 1050 1054 pThis->fEndOfStream = true; 1051 1055 RTVfsIoStrmSkip(pThis->hVfsIos, pThis->cbPadding); 1052 }1053 1054 return rc;1055 }1056 1057 1058 /**1059 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead}1060 */1061 static DECLCALLBACK(int) rtZipTarFssIos_Read(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)1062 {1063 PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis;1064 int rc;1065 AssertReturn(off == -1, VERR_INVALID_PARAMETER);1066 1067 if (pSgBuf->cSegs == 1)1068 rc = rtZipTarFssIos_ReadOneSeg(pThis, pSgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, fBlocking, pcbRead);1069 else1070 {1071 rc = VINF_SUCCESS;1072 size_t cbRead = 0;1073 size_t cbReadSeg;1074 size_t *pcbReadSeg = pcbRead ? &cbReadSeg : NULL;1075 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)1076 {1077 cbReadSeg = 0;1078 rc = rtZipTarFssIos_ReadOneSeg(pThis, pSgBuf->paSegs[iSeg].pvSeg, pSgBuf->paSegs[iSeg].cbSeg, fBlocking, pcbReadSeg);1079 if (RT_FAILURE(rc))1080 break;1081 if (pcbRead)1082 {1083 cbRead += cbReadSeg;1084 if (cbReadSeg != pSgBuf->paSegs[iSeg].cbSeg)1085 break;1086 }1087 }1088 if (pcbRead)1089 *pcbRead = cbRead;1090 1056 } 1091 1057 … … 1165 1131 }, 1166 1132 RTVFSIOSTREAMOPS_VERSION, 1167 0,1133 RTVFSIOSTREAMOPS_FEAT_NO_SG, 1168 1134 rtZipTarFssIos_Read, 1169 1135 rtZipTarFssIos_Write, … … 1423 1389 pIosData->cbFile = Info.cbObject; 1424 1390 pIosData->offFile = 0; 1391 pIosData->offStart = RTVfsIoStrmTell(pThis->hVfsIos); 1425 1392 pIosData->cbPadding = (uint32_t)(Info.cbAllocated - Info.cbObject); 1426 1393 pIosData->fEndOfStream = false;
Note:
See TracChangeset
for help on using the changeset viewer.