Changeset 39025 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- Oct 19, 2011 9:19:42 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 74438
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/fileio-win.cpp
r37598 r39025 629 629 RTR3DECL(int) RTFileGetSize(RTFILE hFile, uint64_t *pcbSize) 630 630 { 631 /* 632 * GetFileSize works for most handles. 633 */ 634 int rc; 631 635 ULARGE_INTEGER Size; 632 636 Size.LowPart = GetFileSize((HANDLE)RTFileToNative(hFile), &Size.HighPart); … … 634 638 { 635 639 *pcbSize = Size.QuadPart; 636 return VINF_SUCCESS; 637 } 638 639 /* error exit */ 640 return RTErrConvertFromWin32(GetLastError()); 640 if (Size.QuadPart) 641 return VINF_SUCCESS; 642 rc = VINF_SUCCESS; 643 /** @todo Check what GetFileSize returns on disks and volume 644 * handles! */ 645 } 646 else 647 rc = RTErrConvertFromWin32(GetLastError()); 648 #if 0 649 /* 650 * Could it be a volume? 651 */ 652 DISK_GEOMETRY DriveGeo; 653 DWORD cbDriveGeo; 654 if (DeviceIoControl((HANDLE)RTFileToNative(hFile), 655 IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, 656 &DriveGeo, sizeof(DriveGeo), &cbDriveGeo, NULL)) 657 { 658 if ( DriveGeo.MediaType == FixedMedia 659 || DriveGeo.MediaType == RemovableMedia) 660 { 661 *pcbSize = DriveGeo.Cylinders.QuadPart 662 * DriveGeo.TracksPerCylinder 663 * DriveGeo.SectorsPerTrack 664 * DriveGeo.BytesPerSector; 665 666 GET_LENGTH_INFORMATION DiskLenInfo; 667 DWORD Ignored; 668 if (DeviceIoControl((HANDLE)RTFileToNative(hFile), 669 IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, 670 &DiskLenInfo, sizeof(DiskLenInfo), &Ignored, (LPOVERLAPPED)NULL)) 671 { 672 /* IOCTL_DISK_GET_LENGTH_INFO is supported -- override cbSize. */ 673 *pcbSize = DiskLenInfo.Length.QuadPart; 674 } 675 return VINF_SUCCESS; 676 } 677 } 678 #endif 679 680 /* 681 * Return the GetFileSize result if not a volume/disk. 682 */ 683 return rc; 641 684 } 642 685 … … 645 688 { 646 689 /** @todo r=bird: 647 * We might have to make this code OS specific...648 * In the worsecase, we'll have to try GetVolumeInformationByHandle on vista and fall649 * back on NtQueryVolumeInformationFile(,,,, FileFsAttributeInformation) else where, and650 * check for known file system names. (For LAN shares we'll have to figure out the remote651 * file system.) */690 * We might have to make this code OS version specific... In the worse 691 * case, we'll have to try GetVolumeInformationByHandle on vista and fall 692 * back on NtQueryVolumeInformationFile(,,,, FileFsAttributeInformation) 693 * else where, and check for known file system names. (For LAN shares we'll 694 * have to figure out the remote file system.) */ 652 695 return VERR_NOT_IMPLEMENTED; 653 696 }
Note:
See TracChangeset
for help on using the changeset viewer.