| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <shlwapi.h> |
| 7 #include <windows.h> | 8 #include <windows.h> |
| 8 | 9 |
| 9 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 14 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) { | 59 if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free)) { |
| 59 return -1; | 60 return -1; |
| 60 } | 61 } |
| 61 int64 rv = static_cast<int64>(available.QuadPart); | 62 int64 rv = static_cast<int64>(available.QuadPart); |
| 62 if (rv < 0) | 63 if (rv < 0) |
| 63 rv = kint64max; | 64 rv = kint64max; |
| 64 return rv; | 65 return rv; |
| 65 } | 66 } |
| 66 | 67 |
| 67 // static | 68 // static |
| 69 int SysInfo::GetMaximumPathComponentLength(const FilePath& path) { |
| 70 base::ThreadRestrictions::AssertIOAllowed(); |
| 71 if (!path.IsAbsolute()) |
| 72 return -1; |
| 73 |
| 74 // GetVolumeInformationW takes a root path ended with a backslash. |
| 75 std::vector<FilePath::CharType> root(path.value().begin(), |
| 76 path.value().end()); |
| 77 root.resize(root.size() + 2); // space for trailing zero and backslash. |
| 78 PathStripToRootW(&root[0]); |
| 79 PathAddBackslashW(&root[0]); |
| 80 |
| 81 DWORD max_length = 0; |
| 82 if (!GetVolumeInformationW(&root[0], NULL, 0, NULL, &max_length, NULL, NULL, |
| 83 0)) { |
| 84 return -1; |
| 85 } |
| 86 return static_cast<int>(max_length); |
| 87 } |
| 88 |
| 89 // static |
| 68 std::string SysInfo::OperatingSystemName() { | 90 std::string SysInfo::OperatingSystemName() { |
| 69 return "Windows NT"; | 91 return "Windows NT"; |
| 70 } | 92 } |
| 71 | 93 |
| 72 // static | 94 // static |
| 73 std::string SysInfo::OperatingSystemVersion() { | 95 std::string SysInfo::OperatingSystemVersion() { |
| 74 win::OSInfo* os_info = win::OSInfo::GetInstance(); | 96 win::OSInfo* os_info = win::OSInfo::GetInstance(); |
| 75 win::OSInfo::VersionNumber version_number = os_info->version_number(); | 97 win::OSInfo::VersionNumber version_number = os_info->version_number(); |
| 76 std::string version(StringPrintf("%d.%d", version_number.major, | 98 std::string version(StringPrintf("%d.%d", version_number.major, |
| 77 version_number.minor)); | 99 version_number.minor)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, | 140 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
| 119 int32* minor_version, | 141 int32* minor_version, |
| 120 int32* bugfix_version) { | 142 int32* bugfix_version) { |
| 121 win::OSInfo* os_info = win::OSInfo::GetInstance(); | 143 win::OSInfo* os_info = win::OSInfo::GetInstance(); |
| 122 *major_version = os_info->version_number().major; | 144 *major_version = os_info->version_number().major; |
| 123 *minor_version = os_info->version_number().minor; | 145 *minor_version = os_info->version_number().minor; |
| 124 *bugfix_version = 0; | 146 *bugfix_version = 0; |
| 125 } | 147 } |
| 126 | 148 |
| 127 } // namespace base | 149 } // namespace base |
| OLD | NEW |