Changeset 77235 in vbox for trunk/src/VBox/Runtime/generic
- Timestamp:
- Feb 9, 2019 6:30:14 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128742
- Location:
- trunk/src/VBox/Runtime/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/fileio-at-generic.cpp
r77209 r77235 36 36 37 37 38 /**39 * Read bytes from a file at a given offset.40 * This function may modify the file position.41 *42 * @returns iprt status code.43 * @param File Handle to the file.44 * @param off Where to read.45 * @param pvBuf Where to put the bytes we read.46 * @param cbToRead How much to read.47 * @param *pcbRead How much we actually read.48 * If NULL an error will be returned for a partial read.49 */50 38 RTDECL(int) RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead) 51 39 { … … 57 45 58 46 59 /**60 * Write bytes to a file at a given offset.61 * This function may modify the file position.62 *63 * @returns iprt status code.64 * @param File Handle to the file.65 * @param off Where to write.66 * @param pvBuf What to write.67 * @param cbToWrite How much to write.68 * @param *pcbWritten How much we actually wrote.69 * If NULL an error will be returned for a partial write.70 */71 47 RTDECL(int) RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten) 72 48 { -
trunk/src/VBox/Runtime/generic/fileio-sg-generic.cpp
r77209 r77235 32 32 #include <iprt/file.h> 33 33 34 #include <iprt/errcore.h> 34 #include <iprt/assert.h> 35 #include <iprt/err.h> 35 36 36 37 37 /**38 * Read bytes from a file at a given offset into a S/G buffer.39 * This function may modify the file position.40 *41 * @returns iprt status code.42 * @param hFile Handle to the file.43 * @param off Where to read.44 * @param pSgBuf Pointer to the S/G buffer to read into.45 * @param cbToRead How much to read.46 * @param pcbRead How much we actually read.47 * If NULL an error will be returned for a partial read.48 */49 38 RTDECL(int) RTFileSgReadAt(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToRead, size_t *pcbRead) 50 39 { … … 54 43 { 55 44 size_t cbBuf = cbToRead; 56 void *pvBuf = RTSgBufGetNextSegment(pSgBuf, &cbBuf); 45 void *pvBuf = RTSgBufGetNextSegment(pSgBuf, &cbBuf); /** @todo this is wrong as it may advance the buffer past what's actually read. */ 57 46 58 size_t cbThisRead = 0;47 size_t cbThisRead = cbBuf; 59 48 rc = RTFileReadAt(hFile, off, pvBuf, cbBuf, pcbRead ? &cbThisRead : NULL); 60 49 if (RT_SUCCESS(rc)) … … 62 51 else 63 52 break; 64 if ( cbThisRead < cbBuf 65 && pcbRead) 53 if (cbThisRead < cbBuf) 54 { 55 AssertStmt(pcbRead, rc = VERR_INTERNAL_ERROR_2); 66 56 break; 57 } 58 Assert(cbBuf == cbThisRead); 67 59 68 60 cbToRead -= cbBuf; 69 off += cbBuf;61 off += cbBuf; 70 62 } 71 63 … … 77 69 78 70 79 /**80 * Write bytes from a S/G buffer to a file at a given offset.81 * This function may modify the file position.82 *83 * @returns iprt status code.84 * @param hFile Handle to the file.85 * @param off Where to write.86 * @param pSgBuf What to write.87 * @param cbToWrite How much to write.88 * @param pcbWritten How much we actually wrote.89 * If NULL an error will be returned for a partial write.90 */91 71 RTDECL(int) RTFileSgWriteAt(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToWrite, size_t *pcbWritten) 92 72 { … … 96 76 { 97 77 size_t cbBuf = cbToWrite; 98 void *pvBuf = RTSgBufGetNextSegment(pSgBuf, &cbBuf); 78 void *pvBuf = RTSgBufGetNextSegment(pSgBuf, &cbBuf); /** @todo this is wrong as it may advance the buffer past what's actually read. */ 99 79 100 size_t cbThisWritten = 0;80 size_t cbThisWritten = cbBuf; 101 81 rc = RTFileWriteAt(hFile, off, pvBuf, cbBuf, pcbWritten ? &cbThisWritten : NULL); 102 82 if (RT_SUCCESS(rc)) … … 104 84 else 105 85 break; 106 if ( cbThisWritten < cbBuf 107 && pcbWritten) 86 if (cbThisWritten < cbBuf) 87 { 88 AssertStmt(pcbWritten, rc = VERR_INTERNAL_ERROR_2); 108 89 break; 90 } 109 91 92 Assert(cbBuf == cbThisWritten); 110 93 cbToWrite -= cbBuf; 111 off += cbBuf;94 off += cbBuf; 112 95 } 113 96
Note:
See TracChangeset
for help on using the changeset viewer.