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

Side by Side Diff: base/file_util_win.cc

Issue 11300011: Don't expand path to use long names in CreateTemporaryFileInDir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 *temp_file = FilePath(temp_name);
cpu_(ooo_6.6-7.5) 2012/11/09 17:21:47 In principle I agree with you assessment but I wou
397 if (path_len > MAX_PATH + 1 || path_len == 0) {
398 DPLOG(WARNING) << "Failed to get long path name for " << temp_name;
399 return false;
400 }
401
402 std::wstring temp_file_str;
403 temp_file_str.assign(temp_name, path_len);
404 *temp_file = FilePath(temp_file_str);
405 return true; 397 return true;
406 } 398 }
407 399
408 bool CreateTemporaryDirInDir(const FilePath& base_dir, 400 bool CreateTemporaryDirInDir(const FilePath& base_dir,
409 const FilePath::StringType& prefix, 401 const FilePath::StringType& prefix,
410 FilePath* new_dir) { 402 FilePath* new_dir) {
411 base::ThreadRestrictions::AssertIOAllowed(); 403 base::ThreadRestrictions::AssertIOAllowed();
412 404
413 FilePath path_to_create; 405 FilePath path_to_create;
414 srand(static_cast<uint32>(time(NULL))); 406 srand(static_cast<uint32>(time(NULL)));
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 HANDLE cp = GetCurrentProcess(); 954 HANDLE cp = GetCurrentProcess();
963 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { 955 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) {
964 *nt_path = FilePath(mapped_file_path); 956 *nt_path = FilePath(mapped_file_path);
965 success = true; 957 success = true;
966 } 958 }
967 ::UnmapViewOfFile(file_view); 959 ::UnmapViewOfFile(file_view);
968 return success; 960 return success;
969 } 961 }
970 962
971 } // namespace file_util 963 } // namespace file_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698