Changeset 6421 in vbox
- Timestamp:
- Jan 21, 2008 5:48:46 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27387
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/file.h
r5999 r6421 266 266 267 267 /** 268 * Determine the maximum file size depending on the file system the file is stored on. 269 */ 270 RTR3DECL(uint64_t) RTFileGetMaxSize(RTFILE File); 271 272 /** 268 273 * Gets the current file position. 269 274 * -
trunk/src/VBox/Runtime/r3/fileio.cpp
r5999 r6421 215 215 AssertMsgFailed(("RTFileSeek(%d) -> %d\n", File, rc)); 216 216 return ~0ULL; 217 } 218 219 220 /** 221 * Determine the maximum file size. Tested on Windows and Linux. 222 */ 223 RTR3DECL(uint64_t) RTFileGetMaxSize(RTFILE File) 224 { 225 uint64_t offLow = 0; 226 uint64_t offHigh = 8 * _1T; /* we don't need bigger files */ 227 uint64_t offOld = RTFileTell(File); 228 229 for (;;) 230 { 231 uint64_t interval = (offHigh - offLow) >> 1; 232 if (interval == 0) 233 { 234 RTFileSeek(File, offOld, RTFILE_SEEK_BEGIN, NULL); 235 return offLow; 236 } 237 if (RT_FAILURE(RTFileSeek(File, offLow + interval, RTFILE_SEEK_BEGIN, NULL))) 238 offHigh = offLow + interval; 239 else 240 offLow = offLow + interval; 241 } 217 242 } 218 243 -
trunk/src/VBox/Runtime/testcase/tstFile.cpp
r5999 r6421 49 49 return 1; 50 50 } 51 52 RTPrintf("Maximum file size is %lld bytes.\n", RTFileGetMaxSize(File)); 51 53 52 54 /* grow file beyond 2G */
Note:
See TracChangeset
for help on using the changeset viewer.