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