OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return AmountOfMemory(&MEMORYSTATUSEX::ullAvailPhys); | 49 return AmountOfMemory(&MEMORYSTATUSEX::ullAvailPhys); |
50 } | 50 } |
51 | 51 |
52 // static | 52 // static |
53 int64_t SysInfo::AmountOfVirtualMemory() { | 53 int64_t SysInfo::AmountOfVirtualMemory() { |
54 return AmountOfMemory(&MEMORYSTATUSEX::ullTotalVirtual); | 54 return AmountOfMemory(&MEMORYSTATUSEX::ullTotalVirtual); |
55 } | 55 } |
56 | 56 |
57 // static | 57 // static |
58 int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { | 58 int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { |
| 59 int64_t available, unused; |
| 60 if (!GetDiskSpaceInfo(path, &available, &unused)) |
| 61 return -1; |
| 62 return available; |
| 63 } |
| 64 |
| 65 // static |
| 66 bool SysInfo::GetDiskSpaceInfo(const FilePath& path, |
| 67 int64_t* available_bytes, |
| 68 int64_t* total_bytes) { |
59 ThreadRestrictions::AssertIOAllowed(); | 69 ThreadRestrictions::AssertIOAllowed(); |
60 | 70 |
61 ULARGE_INTEGER available, total, free; | 71 ULARGE_INTEGER available, total, free; |
62 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) | 72 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) |
63 return -1; | 73 return false; |
64 | 74 |
65 int64_t rv = static_cast<int64_t>(available.QuadPart); | 75 *available_bytes = static_cast<int64_t>(available.QuadPart); |
66 return rv < 0 ? std::numeric_limits<int64_t>::max() : rv; | 76 if (*available_bytes < 0) |
| 77 *available_bytes = std::numeric_limits<int64_t>::max(); |
| 78 *total_bytes = static_cast<int64_t>(total.QuadPart); |
| 79 if (*total_bytes < 0) |
| 80 *total_bytes = std::numeric_limits<int64_t>::max(); |
| 81 return true; |
67 } | 82 } |
68 | 83 |
69 std::string SysInfo::OperatingSystemName() { | 84 std::string SysInfo::OperatingSystemName() { |
70 return "Windows NT"; | 85 return "Windows NT"; |
71 } | 86 } |
72 | 87 |
73 // static | 88 // static |
74 std::string SysInfo::OperatingSystemVersion() { | 89 std::string SysInfo::OperatingSystemVersion() { |
75 win::OSInfo* os_info = win::OSInfo::GetInstance(); | 90 win::OSInfo* os_info = win::OSInfo::GetInstance(); |
76 win::OSInfo::VersionNumber version_number = os_info->version_number(); | 91 win::OSInfo::VersionNumber version_number = os_info->version_number(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, | 135 void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, |
121 int32_t* minor_version, | 136 int32_t* minor_version, |
122 int32_t* bugfix_version) { | 137 int32_t* bugfix_version) { |
123 win::OSInfo* os_info = win::OSInfo::GetInstance(); | 138 win::OSInfo* os_info = win::OSInfo::GetInstance(); |
124 *major_version = os_info->version_number().major; | 139 *major_version = os_info->version_number().major; |
125 *minor_version = os_info->version_number().minor; | 140 *minor_version = os_info->version_number().minor; |
126 *bugfix_version = 0; | 141 *bugfix_version = 0; |
127 } | 142 } |
128 | 143 |
129 } // namespace base | 144 } // namespace base |
OLD | NEW |