- Timestamp:
- May 19, 2008 11:34:46 AM (17 years ago)
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/fileio.cpp
r8245 r8913 239 239 int rc = RTFileGetMaxSizeEx(File, &cbMax); 240 240 return RT_SUCCESS(rc) ? cbMax : -1; 241 }242 243 244 /**245 * Determine the maximum file size.246 *247 * @returns IPRT status code.248 * @param File Handle to the file.249 * @param pcbMax Where to store the max file size.250 * @see RTFileGetMaxSize.251 */252 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax)253 {254 /*255 * Save the current location256 */257 uint64_t offOld;258 int rc = RTFileSeek(File, 0, RTFILE_SEEK_CURRENT, &offOld);259 if (RT_FAILURE(rc))260 return rc;261 262 /*263 * Perform a binary search for the max file size.264 */265 uint64_t offLow = 0;266 uint64_t offHigh = 8 * _1T; /* we don't need bigger files */267 /** @todo r=bird: This isn't doing the trick for windows (at least not vista).268 * Close to offHigh is returned regardless of NTFS or FAT32.269 * We might have to make this code OS specific...270 * In the worse case, we'll have to try GetVolumeInformationByHandle on vista and fall271 * back on NtQueryVolumeInformationFile(,,,, FileFsAttributeInformation) else where, and272 * check for known file system names. (For LAN shares we'll have to figure out the remote273 * file system.) */274 //uint64_t offHigh = INT64_MAX;275 for (;;)276 {277 uint64_t cbInterval = (offHigh - offLow) >> 1;278 if (cbInterval == 0)279 {280 if (pcbMax)281 *pcbMax = offLow;282 return RTFileSeek(File, offOld, RTFILE_SEEK_BEGIN, NULL);283 }284 285 rc = RTFileSeek(File, offLow + cbInterval, RTFILE_SEEK_BEGIN, NULL);286 if (RT_FAILURE(rc))287 offHigh = offLow + cbInterval;288 else289 offLow = offLow + cbInterval;290 }291 241 } 292 242 -
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 { -
trunk/src/VBox/Runtime/r3/win/fileio-win.cpp
r8560 r8913 496 496 497 497 498 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax) 499 { 500 /** @todo r=bird: 501 * We might have to make this code OS specific... 502 * In the worse case, we'll have to try GetVolumeInformationByHandle on vista and fall 503 * back on NtQueryVolumeInformationFile(,,,, FileFsAttributeInformation) else where, and 504 * check for known file system names. (For LAN shares we'll have to figure out the remote 505 * file system.) */ 506 return VERR_NOT_IMPLEMENTED; 507 } 508 509 498 510 RTR3DECL(bool) RTFileIsValid(RTFILE File) 499 511 {
Note:
See TracChangeset
for help on using the changeset viewer.