Changeset 8913 in vbox for trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp
- Timestamp:
- May 19, 2008 11:34:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp
r8561 r8913 393 393 394 394 395 /** 396 * Determine the maximum file size. 397 * 398 * @returns IPRT status code. 399 * @param File Handle to the file. 400 * @param pcbMax Where to store the max file size. 401 * @see RTFileGetMaxSize. 402 */ 403 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax) 404 { 405 /* 406 * Save the current location 407 */ 408 uint64_t offOld; 409 int rc = RTFileSeek(File, 0, RTFILE_SEEK_CURRENT, &offOld); 410 if (RT_FAILURE(rc)) 411 return rc; 412 413 /* 414 * Perform a binary search for the max file size. 415 */ 416 uint64_t offLow = 0; 417 uint64_t offHigh = 8 * _1T; /* we don't need bigger files */ 418 /** @todo Unfortunately this does not work for certain file system types, 419 * for instance cifs mounts. Even worse, statvfs.f_fsid returns 0 for such 420 * file systems. */ 421 //uint64_t offHigh = INT64_MAX; 422 for (;;) 423 { 424 uint64_t cbInterval = (offHigh - offLow) >> 1; 425 if (cbInterval == 0) 426 { 427 if (pcbMax) 428 *pcbMax = offLow; 429 return RTFileSeek(File, offOld, RTFILE_SEEK_BEGIN, NULL); 430 } 431 432 rc = RTFileSeek(File, offLow + cbInterval, RTFILE_SEEK_BEGIN, NULL); 433 if (RT_FAILURE(rc)) 434 offHigh = offLow + cbInterval; 435 else 436 offLow = offLow + cbInterval; 437 } 438 } 439 440 395 441 RTR3DECL(bool) RTFileIsValid(RTFILE File) 396 442 {
Note:
See TracChangeset
for help on using the changeset viewer.