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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 | 56 |
57 // static | 57 // static |
58 int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { | 58 int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { |
59 ThreadRestrictions::AssertIOAllowed(); | 59 ThreadRestrictions::AssertIOAllowed(); |
60 | 60 |
61 ULARGE_INTEGER available, total, free; | 61 ULARGE_INTEGER available, total, free; |
62 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) | 62 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) |
63 return -1; | 63 return -1; |
64 | 64 |
65 int64_t rv = static_cast<int64_t>(available.QuadPart); | 65 int64_t rv = static_cast<int64_t>(available.QuadPart); |
66 return rv < 0 ? std::numeric_limits<int64_t>::max() : rv; | 66 return rv < 0 ? std::numeric_limits<int64_t>::max() : rv; |
Dan Beam
2016/06/09 17:20:13
what about this logic?
fukino
2016/06/10 01:33:36
Added the logic inside GetDiskSpaceInfo to cover t
| |
67 } | 67 } |
68 | 68 |
69 // static | |
70 bool SysInfo::GetDiskSpaceInfo(const FilePath& path, | |
71 int64_t* available_bytes, | |
72 int64_t* total_bytes) { | |
73 ThreadRestrictions::AssertIOAllowed(); | |
74 | |
75 ULARGE_INTEGER available, total, free; | |
76 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) | |
77 return false; | |
78 | |
79 *available_bytes = static_cast<int64_t>(available.QuadPart); | |
80 *total_bytes = static_cast<int64_t>(total.QuadPart); | |
81 return true; | |
82 } | |
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(); |
77 std::string version(StringPrintf("%d.%d.%d", version_number.major, | 92 std::string version(StringPrintf("%d.%d.%d", version_number.major, |
78 version_number.minor, | 93 version_number.minor, |
(...skipping 41 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 |