| Index: base/file_util_win.cc | 
| diff --git a/base/file_util_win.cc b/base/file_util_win.cc | 
| index 199a7cfcce11c496e10a34b05033ff66e7e32cd2..a5f7e4cc161c5bb61bd287c5a1ae457aed86d615 100644 | 
| --- a/base/file_util_win.cc | 
| +++ b/base/file_util_win.cc | 
| @@ -10,6 +10,7 @@ | 
| #include <shlobj.h> | 
| #include <time.h> | 
|  | 
| +#include <algorithm> | 
| #include <limits> | 
| #include <string> | 
|  | 
| @@ -950,4 +951,28 @@ bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) { | 
| return success; | 
| } | 
|  | 
| +int GetMaximumPathComponentLength(const FilePath& path) { | 
| +  base::ThreadRestrictions::AssertIOAllowed(); | 
| + | 
| +  wchar_t volume_path[MAX_PATH]; | 
| +  if (!GetVolumePathNameW(path.NormalizePathSeparators().value().c_str(), | 
| +                          volume_path, | 
| +                          arraysize(volume_path))) { | 
| +    return -1; | 
| +  } | 
| + | 
| +  DWORD max_length = 0; | 
| +  if (!GetVolumeInformationW(volume_path, NULL, 0, NULL, &max_length, NULL, | 
| +                             NULL, 0)) { | 
| +    return -1; | 
| +  } | 
| + | 
| +  // Length of |path| with path separator appended. | 
| +  size_t prefix = path.StripTrailingSeparators().value().size() + 1; | 
| +  // The whole path string must be shorter than MAX_PATH. That is, it must be | 
| +  // prefix + component_length < MAX_PATH (or equivalently, <= MAX_PATH - 1). | 
| +  int whole_path_limit = std::max(0, MAX_PATH - 1 - static_cast<int>(prefix)); | 
| +  return std::min(whole_path_limit, static_cast<int>(max_length)); | 
| +} | 
| + | 
| }  // namespace file_util | 
|  |