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

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: Partially addressed review comments (#3). 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..d6ea16bedcdd22b9c80af643e11c7df8edf528b6 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -4,6 +4,7 @@
#include "base/sys_info.h"
+#include <shlwapi.h>
#include <windows.h>
#include "base/file_path.h"
@@ -65,6 +66,27 @@ int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
}
// static
+int SysInfo::GetMaximumPathComponentLength(const FilePath& path) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (!path.IsAbsolute())
Mark Mentovai 2013/02/08 18:14:42 Same.
kinaba 2013/02/12 05:51:29 Done.
+ return -1;
+
+ // GetVolumeInformationW takes a root path ended with a backslash.
+ std::vector<FilePath::CharType> root(path.value().begin(),
+ path.value().end());
+ root.resize(root.size() + 2); // space for trailing zero 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