Changeset 100908 in vbox for trunk/src/VBox/Runtime/common/vfs
- Timestamp:
- Aug 19, 2023 2:57:05 AM (17 months ago)
- Location:
- trunk/src/VBox/Runtime/common/vfs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r98103 r100908 110 110 AssertPtrNull((pDirOps)->pfnCreateDir); \ 111 111 AssertPtrNull((pDirOps)->pfnOpenSymlink); \ 112 AssertPtr((pDirOps)->pfnCreateSymlink); \ 113 AssertPtr((pDirOps)->pfnUnlinkEntry); \ 112 AssertPtrNull((pDirOps)->pfnCreateSymlink); \ 113 AssertPtrNull((pDirOps)->pfnUnlinkEntry); \ 114 AssertPtrNull((pDirOps)->pfnRenameEntry); \ 114 115 AssertPtr((pDirOps)->pfnRewindDir); \ 115 116 AssertPtr((pDirOps)->pfnReadDir); \ … … 3241 3242 3242 3243 RTVfsLockAcquireWrite(pVfsParentDir->Base.hLock); 3243 rc = pVfsParentDir->pOps->pfnUnlinkEntry(pVfsParentDir->Base.pvThis, pszEntryName, RTFS_TYPE_DIRECTORY); 3244 if (pVfsParentDir->pOps->pfnUnlinkEntry) 3245 rc = pVfsParentDir->pOps->pfnUnlinkEntry(pVfsParentDir->Base.pvThis, pszEntryName, RTFS_TYPE_DIRECTORY); 3246 else 3247 rc = VERR_NOT_SUPPORTED; 3244 3248 RTVfsLockReleaseWrite(pVfsParentDir->Base.hLock); 3245 3249 … … 3612 3616 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbRead); 3613 3617 RTVfsLockReleaseWrite(pThis->Base.hLock); 3618 Assert(rc != VINF_SUCCESS || RTSgBufIsAtEnd(&SgBuf)); 3614 3619 return rc; 3615 3620 } … … 3635 3640 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbRead); 3636 3641 RTVfsLockReleaseWrite(pThis->Base.hLock); 3642 Assert(rc != VINF_SUCCESS || RTSgBufIsAtEnd(&SgBuf)); 3637 3643 return rc; 3638 3644 } … … 3660 3666 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten); 3661 3667 RTVfsLockReleaseWrite(pThis->Base.hLock); 3668 Assert(!pcbWritten || *pcbWritten + RTSgBufCalcLengthLeft(&SgBuf) == cbToWrite || RT_FAILURE(rc)); 3662 3669 } 3663 3670 else … … 3689 3696 rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbWritten); 3690 3697 RTVfsLockReleaseWrite(pThis->Base.hLock); 3698 Assert(!pcbWritten || *pcbWritten + RTSgBufCalcLengthLeft(&SgBuf) == cbToWrite || RT_FAILURE(rc)); 3691 3699 } 3692 3700 else … … 3696 3704 3697 3705 3698 RTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)3706 RTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 3699 3707 { 3700 3708 AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER); … … 3717 3725 rc = VINF_SUCCESS; 3718 3726 3719 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)3727 while (!RTSgBufIsAtEnd(pSgBuf)) 3720 3728 { 3721 3729 RTSGBUF SgBuf; 3722 RTSgBufInit(&SgBuf, &pSgBuf->paSegs[iSeg], 1); 3723 3724 size_t cbReadSeg = pcbRead ? 0 : pSgBuf->paSegs[iSeg].cbSeg; 3730 RTSGSEG SgSeg; 3731 SgSeg.pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &SgSeg.cbSeg); 3732 RTSgBufInit(&SgBuf, &SgSeg, 1); 3733 3734 size_t cbReadSeg = pcbRead ? 0 : SgSeg.cbSeg; 3725 3735 rc = pThis->pOps->pfnRead(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbRead ? &cbReadSeg : NULL); 3726 3736 if (RT_FAILURE(rc)) 3727 3737 break; 3728 3738 cbRead += cbReadSeg; 3729 if ((pcbRead && cbReadSeg != SgBuf.paSegs[0].cbSeg) || rc != VINF_SUCCESS) 3739 RTSgBufAdvance(pSgBuf, cbReadSeg); 3740 if ((pcbRead && cbReadSeg != SgSeg.cbSeg) || rc != VINF_SUCCESS) 3730 3741 break; 3731 3742 if (off != -1) … … 3737 3748 } 3738 3749 RTVfsLockReleaseWrite(pThis->Base.hLock); 3739 return rc; 3740 } 3741 3742 3743 RTDECL(int) RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 3750 Assert(rc != VINF_SUCCESS || RTSgBufIsAtEnd(pSgBuf)); 3751 return rc; 3752 } 3753 3754 3755 RTDECL(int) RTVfsIoStrmSgWrite(RTVFSIOSTREAM hVfsIos, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 3744 3756 { 3745 3757 AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER); … … 3764 3776 rc = VINF_SUCCESS; 3765 3777 3766 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)3778 while (!RTSgBufIsAtEnd(pSgBuf)) 3767 3779 { 3768 3780 RTSGBUF SgBuf; 3769 RTSgBufInit(&SgBuf, &pSgBuf->paSegs[iSeg], 1); 3781 RTSGSEG SgSeg; 3782 SgSeg.pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &SgSeg.cbSeg); 3783 RTSgBufInit(&SgBuf, &SgSeg, 1); 3770 3784 3771 3785 size_t cbWrittenSeg = 0; … … 3776 3790 { 3777 3791 cbWritten += cbWrittenSeg; 3778 if (cbWrittenSeg != SgBuf.paSegs[0].cbSeg) 3792 RTSgBufAdvance(pSgBuf, cbWrittenSeg); 3793 if (cbWrittenSeg != SgSeg.cbSeg) 3779 3794 break; 3780 3795 if (off != -1) 3781 3796 off += cbWrittenSeg; 3782 3797 } 3783 else if (off != -1) 3784 off += pSgBuf->paSegs[iSeg].cbSeg; 3798 else 3799 { 3800 RTSgBufAdvance(pSgBuf, SgSeg.cbSeg); 3801 if (off != -1) 3802 off += SgSeg.cbSeg; 3803 } 3785 3804 } 3786 3805 … … 4232 4251 4233 4252 4234 RTDECL(int) RTVfsFileSgRead(RTVFSFILE hVfsFile, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)4253 RTDECL(int) RTVfsFileSgRead(RTVFSFILE hVfsFile, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 4235 4254 { 4236 4255 AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER); … … 4245 4264 4246 4265 4247 RTDECL(int) RTVfsFileSgWrite(RTVFSFILE hVfsFile, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)4266 RTDECL(int) RTVfsFileSgWrite(RTVFSFILE hVfsFile, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 4248 4267 { 4249 4268 AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER); -
trunk/src/VBox/Runtime/common/vfs/vfsmemory.cpp
r98103 r100908 264 264 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 265 265 */ 266 static DECLCALLBACK(int) rtVfsMemFile_Read(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)266 static DECLCALLBACK(int) rtVfsMemFile_Read(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 267 267 { 268 268 PRTVFSMEMFILE pThis = (PRTVFSMEMFILE)pvThis; … … 305 305 if (cbLeftToRead > 0) 306 306 { 307 RTSgBufAdvance(pSgBuf, cbLeftToRead); 308 307 309 uint8_t *pbDst = (uint8_t *)pSgBuf->paSegs[0].pvSeg; 308 310 bool fHit; … … 458 460 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite} 459 461 */ 460 static DECLCALLBACK(int) rtVfsMemFile_Write(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)462 static DECLCALLBACK(int) rtVfsMemFile_Write(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 461 463 { 462 464 PRTVFSMEMFILE pThis = (PRTVFSMEMFILE)pvThis; … … 551 553 pThis->Base.ObjInfo.cbObject = offUnsigned; 552 554 555 size_t const cbWritten = pSgBuf->paSegs[0].cbSeg - cbLeftToWrite; 553 556 if (pcbWritten) 554 *pcbWritten = pSgBuf->paSegs[0].cbSeg - cbLeftToWrite; 557 *pcbWritten = cbWritten; 558 RTSgBufAdvance(pSgBuf, cbWritten); 555 559 return rc; 556 560 } -
trunk/src/VBox/Runtime/common/vfs/vfsprogress.cpp
r98103 r100908 149 149 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 150 150 */ 151 static DECLCALLBACK(int) rtVfsProgressFile_Read(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)151 static DECLCALLBACK(int) rtVfsProgressFile_Read(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 152 152 { 153 153 PRTVFSPROGRESSFILE pThis = (PRTVFSPROGRESSFILE)pvThis; … … 166 166 167 167 /* Calc the request before calling down the stack. */ 168 size_t cbReq = 0; 169 unsigned i = pSgBuf->cSegs; 170 while (i-- > 0) 171 cbReq += pSgBuf->paSegs[i].cbSeg; 168 size_t const cbReq = RTSgBufCalcLengthLeft(pSgBuf); 172 169 173 170 /* Do the read. */ … … 188 185 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite} 189 186 */ 190 static DECLCALLBACK(int) rtVfsProgressFile_Write(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)187 static DECLCALLBACK(int) rtVfsProgressFile_Write(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 191 188 { 192 189 PRTVFSPROGRESSFILE pThis = (PRTVFSPROGRESSFILE)pvThis; … … 205 202 206 203 /* Calc the request before calling down the stack. */ 207 size_t cbReq = 0; 208 unsigned i = pSgBuf->cSegs; 209 while (i-- > 0) 210 cbReq += pSgBuf->paSegs[i].cbSeg; 204 size_t const cbReq = RTSgBufCalcLengthLeft(pSgBuf); 211 205 212 206 /* Do the read. */ -
trunk/src/VBox/Runtime/common/vfs/vfsreadahead.cpp
r98103 r100908 212 212 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 213 213 */ 214 static DECLCALLBACK(int) rtVfsReadAhead_Read(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)214 static DECLCALLBACK(int) rtVfsReadAhead_Read(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 215 215 { 216 216 PRTVFSREADAHEAD pThis = (PRTVFSREADAHEAD)pvThis; … … 348 348 *pcbRead = cbTotalRead; 349 349 Assert(cbTotalRead <= pSgBuf->paSegs[0].cbSeg); 350 RTSgBufAdvance(pSgBuf, cbTotalRead); 350 351 351 352 return rc; … … 356 357 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite} 357 358 */ 358 static DECLCALLBACK(int) rtVfsReadAhead_Write(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)359 static DECLCALLBACK(int) rtVfsReadAhead_Write(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 359 360 { 360 361 RT_NOREF_PV(pvThis); RT_NOREF_PV(off); RT_NOREF_PV(pSgBuf); RT_NOREF_PV(fBlocking); RT_NOREF_PV(pcbWritten); -
trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
r98103 r100908 142 142 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 143 143 */ 144 static DECLCALLBACK(int) rtVfsStdFile_Read(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)144 static DECLCALLBACK(int) rtVfsStdFile_Read(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 145 145 { 146 146 PRTVFSSTDFILE pThis = (PRTVFSSTDFILE)pvThis; … … 150 150 if (pSgBuf->cSegs == 1) 151 151 { 152 size_t cbToRead = 0; 153 void * const pvDst = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbToRead); 154 152 155 if (off < 0) 153 rc = RTFileRead( pThis->hFile, pSgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, pcbRead);156 rc = RTFileRead(pThis->hFile, pvDst, cbToRead, pcbRead); 154 157 else 155 158 { 156 rc = RTFileReadAt(pThis->hFile, off, p SgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, pcbRead);159 rc = RTFileReadAt(pThis->hFile, off, pvDst, cbToRead, pcbRead); 157 160 if (RT_SUCCESS(rc)) /* RTFileReadAt() doesn't increment the file-position indicator on some platforms */ 158 rc = RTFileSeek(pThis->hFile, off + (pcbRead ? *pcbRead : pSgBuf->paSegs[0].cbSeg), RTFILE_SEEK_BEGIN, NULL);161 rc = RTFileSeek(pThis->hFile, off + (pcbRead ? *pcbRead : cbToRead), RTFILE_SEEK_BEGIN, NULL); 159 162 } 160 163 if (rc == VINF_SUCCESS && pcbRead) 161 rc = rtVfsStdFile_ReadFixRC(pThis, off, pSgBuf->paSegs[0].cbSeg, *pcbRead); 164 rc = rtVfsStdFile_ReadFixRC(pThis, off, cbToRead, *pcbRead); 165 if (RT_SUCCESS(rc)) 166 RTSgBufAdvance(pSgBuf, pcbRead ? *pcbRead : cbToRead); 162 167 } 163 168 else 164 169 { 165 size_t cbSeg = 0; 166 size_t cbRead = 0; 167 size_t cbReadSeg = 0; 170 size_t cbSeg = 0; 171 size_t cbRead = 0; 168 172 rc = VINF_SUCCESS; 169 173 170 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)174 while (!RTSgBufIsAtEnd(pSgBuf)) 171 175 { 172 void *pvSeg = pSgBuf->paSegs[iSeg].pvSeg; 173 cbSeg = pSgBuf->paSegs[iSeg].cbSeg; 174 175 cbReadSeg = cbSeg; 176 void * const pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbSeg); 177 178 size_t cbReadSeg = cbSeg; 176 179 if (off < 0) 177 180 rc = RTFileRead( pThis->hFile, pvSeg, cbSeg, pcbRead ? &cbReadSeg : NULL); … … 184 187 if (RT_FAILURE(rc)) 185 188 break; 189 186 190 if (off >= 0) 187 191 off += cbReadSeg; 188 192 cbRead += cbReadSeg; 193 RTSgBufAdvance(pSgBuf, cbReadSeg); 194 189 195 if ((pcbRead && cbReadSeg != cbSeg) || rc != VINF_SUCCESS) 190 196 break; … … 195 201 *pcbRead = cbRead; 196 202 if (rc == VINF_SUCCESS) 197 rc = rtVfsStdFile_ReadFixRC(pThis, off, cbSeg, cbRead Seg);203 rc = rtVfsStdFile_ReadFixRC(pThis, off, cbSeg, cbRead); 198 204 } 199 205 } … … 206 212 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite} 207 213 */ 208 static DECLCALLBACK(int) rtVfsStdFile_Write(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)214 static DECLCALLBACK(int) rtVfsStdFile_Write(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 209 215 { 210 216 PRTVFSSTDFILE pThis = (PRTVFSSTDFILE)pvThis; … … 214 220 if (pSgBuf->cSegs == 1) 215 221 { 222 size_t cbToWrite = 0; 223 void const * const pvSrc = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbToWrite); 224 216 225 if (off < 0) 217 rc = RTFileWrite(pThis->hFile, p SgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, pcbWritten);226 rc = RTFileWrite(pThis->hFile, pvSrc, cbToWrite, pcbWritten); 218 227 else 219 228 { 220 rc = RTFileWriteAt(pThis->hFile, off, p SgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, pcbWritten);229 rc = RTFileWriteAt(pThis->hFile, off, pvSrc, cbToWrite, pcbWritten); 221 230 if (RT_SUCCESS(rc)) /* RTFileWriteAt() doesn't increment the file-position indicator on some platforms */ 222 rc = RTFileSeek(pThis->hFile, off + (pcbWritten ? *pcbWritten : pSgBuf->paSegs[0].cbSeg), RTFILE_SEEK_BEGIN, 223 NULL); 231 rc = RTFileSeek(pThis->hFile, off + (pcbWritten ? *pcbWritten : cbToWrite), RTFILE_SEEK_BEGIN, NULL); 224 232 } 233 if (RT_SUCCESS(rc)) 234 RTSgBufAdvance(pSgBuf, pcbWritten ? *pcbWritten : cbToWrite); 225 235 } 226 236 else … … 231 241 rc = VINF_SUCCESS; 232 242 233 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)243 while (!RTSgBufIsAtEnd(pSgBuf)) 234 244 { 235 void *pvSeg = pSgBuf->paSegs[iSeg].pvSeg;236 size_t cbSeg = pSgBuf->paSegs[iSeg].cbSeg;245 size_t cbSeg = 0; 246 void const * const pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbSeg); 237 247 238 248 cbWrittenSeg = 0; … … 253 263 if (pcbWritten) 254 264 { 265 RTSgBufAdvance(pSgBuf, cbWrittenSeg); 255 266 cbWritten += cbWrittenSeg; 256 267 if (cbWrittenSeg != cbSeg) 257 268 break; 258 269 } 270 else 271 RTSgBufAdvance(pSgBuf, cbSeg); 259 272 } 260 273 -
trunk/src/VBox/Runtime/common/vfs/vfsstdpipe.cpp
r98103 r100908 97 97 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead} 98 98 */ 99 static DECLCALLBACK(int) rtVfsStdPipe_Read(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)99 static DECLCALLBACK(int) rtVfsStdPipe_Read(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 100 100 { 101 101 PRTVFSSTDPIPE pThis = (PRTVFSSTDPIPE)pvThis; … … 111 111 rc = RTPipeRead( pThis->hPipe, pSgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, pcbRead); 112 112 if (RT_SUCCESS(rc)) 113 pThis->offFakePos += pcbRead ? *pcbRead : pSgBuf->paSegs[0].cbSeg; 113 { 114 size_t const cbAdv = pcbRead ? *pcbRead : pSgBuf->paSegs[0].cbSeg; 115 pThis->offFakePos += cbAdv; 116 RTSgBufAdvance(pSgBuf, cbAdv); 117 } 114 118 } 115 119 else 116 120 { 117 size_t cbSeg = 0;118 121 size_t cbRead = 0; 119 122 size_t cbReadSeg = 0; … … 121 124 rc = VINF_SUCCESS; 122 125 123 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)126 while (!RTSgBufIsAtEnd(pSgBuf)) 124 127 { 125 void *pvSeg = pSgBuf->paSegs[iSeg].pvSeg;126 cbSeg = pSgBuf->paSegs[iSeg].cbSeg;128 size_t cbSeg = 0; 129 void *pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbSeg); 127 130 128 131 cbReadSeg = cbSeg; … … 133 136 if (RT_FAILURE(rc)) 134 137 break; 135 pThis->offFakePos += pcbRead ? cbReadSeg : cbSeg; 136 cbRead += cbReadSeg; 138 139 pThis->offFakePos += cbReadSeg; 140 cbRead += cbReadSeg; 141 RTSgBufAdvance(pSgBuf, cbReadSeg); 137 142 if (rc != VINF_SUCCESS) 138 143 break; … … 151 156 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite} 152 157 */ 153 static DECLCALLBACK(int) rtVfsStdPipe_Write(void *pvThis, RTFOFF off, P CRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)158 static DECLCALLBACK(int) rtVfsStdPipe_Write(void *pvThis, RTFOFF off, PRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 154 159 { 155 160 PRTVFSSTDPIPE pThis = (PRTVFSSTDPIPE)pvThis; … … 164 169 rc = RTPipeWrite( pThis->hPipe, pSgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, pcbWritten); 165 170 if (RT_SUCCESS(rc)) 166 pThis->offFakePos += pcbWritten ? *pcbWritten : pSgBuf->paSegs[0].cbSeg; 171 { 172 size_t const cbAdv = pcbWritten ? *pcbWritten : pSgBuf->paSegs[0].cbSeg; 173 pThis->offFakePos += cbAdv; 174 RTSgBufAdvance(pSgBuf, cbAdv); 175 } 167 176 } 168 177 else … … 173 182 rc = VINF_SUCCESS; 174 183 175 for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)184 while (!RTSgBufIsAtEnd(pSgBuf)) 176 185 { 177 void *pvSeg = pSgBuf->paSegs[iSeg].pvSeg;178 size_t cbSeg = pSgBuf->paSegs[iSeg].cbSeg;186 size_t cbSeg = 0; 187 void const *pvSeg = RTSgBufGetCurrentSegment(pSgBuf, ~(size_t)0, &cbSeg); 179 188 180 189 cbWrittenSeg = 0; … … 185 194 if (RT_FAILURE(rc)) 186 195 break; 187 pThis->offFakePos += pcbWritten ? cbWrittenSeg : cbSeg; 196 197 size_t const cbAdv = pcbWritten ? cbWrittenSeg : cbSeg; 198 pThis->offFakePos += cbAdv; 199 RTSgBufAdvance(pSgBuf, cbAdv); 200 188 201 if (pcbWritten) 189 202 {
Note:
See TracChangeset
for help on using the changeset viewer.