Correct GetDriveType error handling.

BUG=4020
R=brucedawson@google.com, juberti@webrtc.org, pthatcher@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/36899005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@8127 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
jlmiller@webrtc.org 2015-01-22 17:44:19 +00:00
parent 043db24767
commit ea1c84285c
2 changed files with 13 additions and 12 deletions

View File

@ -378,8 +378,9 @@ bool Win32Filesystem::GetAppTempFolder(Pathname* path) {
return GetTemporaryFolder(*path, true, &filename);
}
bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) {
if (!freebytes) {
bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path,
int64 *free_bytes) {
if (!free_bytes) {
return false;
}
char drive[4];
@ -398,24 +399,24 @@ bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) {
// TODO: Add method to Pathname to determine if the path is relative.
// TODO: Add method to Pathname to convert a path to absolute.
}
UINT driveType = ::GetDriveType(target_drive);
if ( (driveType & DRIVE_REMOTE) || (driveType & DRIVE_UNKNOWN) ) {
LOG(LS_VERBOSE) << " remove or unknown drive " << drive;
UINT drive_type = ::GetDriveType(target_drive);
if ((drive_type == DRIVE_REMOTE) || (drive_type == DRIVE_UNKNOWN)) {
LOG(LS_VERBOSE) << "Remote or unknown drive: " << drive;
return false;
}
int64 totalNumberOfBytes; // receives the number of bytes on disk
int64 totalNumberOfFreeBytes; // receives the free bytes on disk
int64 total_number_of_bytes; // receives the number of bytes on disk
int64 total_number_of_free_bytes; // receives the free bytes on disk
// make sure things won't change in 64 bit machine
// TODO replace with compile time assert
ASSERT(sizeof(ULARGE_INTEGER) == sizeof(uint64)); //NOLINT
if (::GetDiskFreeSpaceEx(target_drive,
(PULARGE_INTEGER)freebytes,
(PULARGE_INTEGER)&totalNumberOfBytes,
(PULARGE_INTEGER)&totalNumberOfFreeBytes)) {
(PULARGE_INTEGER)free_bytes,
(PULARGE_INTEGER)&total_number_of_bytes,
(PULARGE_INTEGER)&total_number_of_free_bytes)) {
return true;
} else {
LOG(LS_VERBOSE) << " GetDiskFreeSpaceEx returns error ";
LOG(LS_VERBOSE) << "GetDiskFreeSpaceEx returns error.";
return false;
}
}

View File

@ -91,7 +91,7 @@ class Win32Filesystem : public FilesystemInterface {
// Get a temporary folder that is unique to the current user and application.
virtual bool GetAppTempFolder(Pathname* path);
virtual bool GetDiskFreeSpace(const Pathname& path, int64 *freebytes);
virtual bool GetDiskFreeSpace(const Pathname& path, int64 *free_bytes);
virtual Pathname GetCurrentDirectory();
};