Chromium Code Reviews| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <psapi.h> | 8 #include <psapi.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 FilePath* temp_file) { | 386 FilePath* temp_file) { |
| 387 base::ThreadRestrictions::AssertIOAllowed(); | 387 base::ThreadRestrictions::AssertIOAllowed(); |
| 388 | 388 |
| 389 wchar_t temp_name[MAX_PATH + 1]; | 389 wchar_t temp_name[MAX_PATH + 1]; |
| 390 | 390 |
| 391 if (!GetTempFileName(dir.value().c_str(), L"", 0, temp_name)) { | 391 if (!GetTempFileName(dir.value().c_str(), L"", 0, temp_name)) { |
| 392 DPLOG(WARNING) << "Failed to get temporary file name in " << dir.value(); | 392 DPLOG(WARNING) << "Failed to get temporary file name in " << dir.value(); |
| 393 return false; | 393 return false; |
| 394 } | 394 } |
| 395 | 395 |
| 396 DWORD path_len = GetLongPathName(temp_name, temp_name, MAX_PATH); | 396 wchar_t long_temp_name[MAX_PATH + 1]; |
|
asanka
2012/11/09 22:02:54
Added |long_temp_name| because I couldn't find any
| |
| 397 if (path_len > MAX_PATH + 1 || path_len == 0) { | 397 DWORD long_name_len = GetLongPathName(temp_name, long_temp_name, MAX_PATH); |
| 398 DPLOG(WARNING) << "Failed to get long path name for " << temp_name; | 398 if (long_name_len > MAX_PATH || long_name_len == 0) { |
| 399 return false; | 399 // GetLongPathName() failed, but we still have a temporary file. |
| 400 *temp_file = FilePath(temp_name); | |
| 401 return true; | |
| 400 } | 402 } |
| 401 | 403 |
| 402 std::wstring temp_file_str; | 404 FilePath::StringType long_temp_name_str; |
| 403 temp_file_str.assign(temp_name, path_len); | 405 long_temp_name_str.assign(long_temp_name, long_name_len); |
| 404 *temp_file = FilePath(temp_file_str); | 406 *temp_file = FilePath(long_temp_name_str); |
| 405 return true; | 407 return true; |
| 406 } | 408 } |
| 407 | 409 |
| 408 bool CreateTemporaryDirInDir(const FilePath& base_dir, | 410 bool CreateTemporaryDirInDir(const FilePath& base_dir, |
| 409 const FilePath::StringType& prefix, | 411 const FilePath::StringType& prefix, |
| 410 FilePath* new_dir) { | 412 FilePath* new_dir) { |
| 411 base::ThreadRestrictions::AssertIOAllowed(); | 413 base::ThreadRestrictions::AssertIOAllowed(); |
| 412 | 414 |
| 413 FilePath path_to_create; | 415 FilePath path_to_create; |
| 414 srand(static_cast<uint32>(time(NULL))); | 416 srand(static_cast<uint32>(time(NULL))); |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 962 HANDLE cp = GetCurrentProcess(); | 964 HANDLE cp = GetCurrentProcess(); |
| 963 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { | 965 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { |
| 964 *nt_path = FilePath(mapped_file_path); | 966 *nt_path = FilePath(mapped_file_path); |
| 965 success = true; | 967 success = true; |
| 966 } | 968 } |
| 967 ::UnmapViewOfFile(file_view); | 969 ::UnmapViewOfFile(file_view); |
| 968 return success; | 970 return success; |
| 969 } | 971 } |
| 970 | 972 |
| 971 } // namespace file_util | 973 } // namespace file_util |
| OLD | NEW |