| Index: base/file_path.cc
|
| ===================================================================
|
| --- base/file_path.cc (revision 69859)
|
| +++ base/file_path.cc (working copy)
|
| @@ -34,6 +34,19 @@
|
| const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL(".");
|
| const FilePath::CharType FilePath::kParentDirectory[] = FILE_PATH_LITERAL("..");
|
|
|
| +#if defined(OS_WIN)
|
| +const FilePath::CharType FilePath::kExtendedPathPrefix[] =
|
| + FILE_PATH_LITERAL("\\\\?\\");
|
| +
|
| +const FilePath::CharType FilePath::kUNCExtendedPathPrefix[] =
|
| + FILE_PATH_LITERAL("\\\\?\\UNC\\");
|
| +
|
| +const FilePath::CharType FilePath::kSharePrefix[] =
|
| + FILE_PATH_LITERAL("\\\\");
|
| +
|
| +const int kSharePrefixLength = 2;
|
| +#endif
|
| +
|
| const FilePath::CharType FilePath::kExtensionSeparator = FILE_PATH_LITERAL('.');
|
|
|
| typedef FilePath::StringType StringType;
|
| @@ -1190,3 +1203,51 @@
|
| return FilePath(copy);
|
| }
|
| #endif
|
| +
|
| +#if defined(OS_WIN)
|
| +// TODO(kkanetkar): Taken from gears. Replace this when
|
| +// crbug.com/67384 is addressed.
|
| +StringType FilePath::ToLongFileNameHack(const StringType& path) const {
|
| + StringType long_path;
|
| + // This cast is for countering the compiler warning.
|
| + DWORD length_to_try = static_cast<DWORD>(path.length() * 2);
|
| + long_path.resize(length_to_try);
|
| + DWORD actual_length = GetLongPathName(path.c_str(),
|
| + &long_path.at(0),
|
| + length_to_try);
|
| + if (actual_length == 0) {
|
| + return path;
|
| + } else if (actual_length <= length_to_try) {
|
| + long_path.resize(actual_length);
|
| + return long_path;
|
| + }
|
| +
|
| + length_to_try = actual_length;
|
| + long_path.resize(length_to_try);
|
| + actual_length = GetLongPathName(path.c_str(),
|
| + &long_path.at(0),
|
| + length_to_try + 1);
|
| + if (actual_length > 0 && actual_length <= length_to_try) {
|
| + long_path.resize(actual_length);
|
| + return long_path;
|
| + } else {
|
| + return path;
|
| + }
|
| +}
|
| +
|
| +FilePath FilePath::GetLongPathHack() const {
|
| + if (StartsWith(path_, kExtendedPathPrefix, false) ||
|
| + StartsWith(path_, kUNCExtendedPathPrefix, false)) {
|
| + return FilePath(path_);
|
| + }
|
| +
|
| + // Note that the 8.3 short file name can not be simply prefixed with the long
|
| + // path prefix. It has to be converted to long file name first.
|
| + if (StartsWith(path_, kSharePrefix, false)) {
|
| + return FilePath(kUNCExtendedPathPrefix + ToLongFileNameHack(
|
| + path_.substr(kSharePrefixLength)));
|
| + } else {
|
| + return FilePath(kExtendedPathPrefix + ToLongFileNameHack(path_));
|
| + }
|
| +}
|
| +#endif
|
|
|