Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Unified Diff: base/sys_info_win.cc

Issue 12212010: Truncate the download file name if it exceeds the filesystem limit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Windows (UTF-16) support. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/sys_info_win.cc
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc
index 98d2f7c951bb28605406ce0657793dc91ca711c8..4b7f03827d1a0fd012fe40c7deb554fc92641ff3 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -4,9 +4,11 @@
#include "base/sys_info.h"
+#include <shlwapi.h>
#include <windows.h>
#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/stringprintf.h"
@@ -65,6 +67,28 @@ int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
}
// static
+int SysInfo::GetMaximumPathComponentLength(const FilePath& path) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ FilePath full_path(path);
+ if (!full_path.IsAbsolute() && !file_util::AbsolutePath(&full_path))
+ return -1;
+
+ // GetVolumeInformationW takes a root path ended with a backslash.
+ std::vector<FilePath::CharType> root(full_path.value().begin(),
+ full_path.value().end());
+ root.resize(root.size() + 2); // +2 for trailing \0 and backslash.
+ PathStripToRootW(&root[0]);
+ PathAddBackslashW(&root[0]);
+
+ DWORD max_length = 0;
+ if (!GetVolumeInformationW(&root[0], NULL, 0, NULL, &max_length, NULL, NULL,
+ 0)) {
+ return -1;
+ }
+ return static_cast<int>(max_length);
+}
+
+// static
std::string SysInfo::OperatingSystemName() {
return "Windows NT";
}

Powered by Google App Engine
This is Rietveld 408576698