| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #include <time.h> | 10 #include <time.h> |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 return false; | 386 return false; |
| 387 // TODO(evanm): the old behavior of this function was to always strip the | 387 // TODO(evanm): the old behavior of this function was to always strip the |
| 388 // trailing slash. We duplicate this here, but it shouldn't be necessary | 388 // trailing slash. We duplicate this here, but it shouldn't be necessary |
| 389 // when everyone is using the appropriate FilePath APIs. | 389 // when everyone is using the appropriate FilePath APIs. |
| 390 std::wstring path_str(temp_path); | 390 std::wstring path_str(temp_path); |
| 391 TrimTrailingSeparator(&path_str); | 391 TrimTrailingSeparator(&path_str); |
| 392 *path = FilePath(path_str); | 392 *path = FilePath(path_str); |
| 393 return true; | 393 return true; |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool CreateTemporaryFileName(std::wstring* temp_file) { | 396 bool CreateTemporaryFileName(FilePath* path) { |
| 397 std::wstring temp_path; | 397 std::wstring temp_path, temp_file; |
| 398 | 398 |
| 399 if (!GetTempDir(&temp_path)) | 399 if (!GetTempDir(&temp_path)) |
| 400 return false; | 400 return false; |
| 401 | 401 |
| 402 return CreateTemporaryFileNameInDir(temp_path, temp_file); | 402 if (CreateTemporaryFileNameInDir(temp_path, &temp_file)) { |
| 403 *path = FilePath(temp_file); |
| 404 return true; |
| 405 } |
| 406 |
| 407 return false; |
| 403 } | 408 } |
| 404 | 409 |
| 405 bool CreateTemporaryFileNameInDir(const std::wstring& dir, | 410 bool CreateTemporaryFileNameInDir(const std::wstring& dir, |
| 406 std::wstring* temp_file) { | 411 std::wstring* temp_file) { |
| 407 wchar_t temp_name[MAX_PATH + 1]; | 412 wchar_t temp_name[MAX_PATH + 1]; |
| 408 | 413 |
| 409 if (!GetTempFileName(dir.c_str(), L"", 0, temp_name)) | 414 if (!GetTempFileName(dir.c_str(), L"", 0, temp_name)) |
| 410 return false; // fail! | 415 return false; // fail! |
| 411 | 416 |
| 412 DWORD path_len = GetLongPathName(temp_name, temp_name, MAX_PATH); | 417 DWORD path_len = GetLongPathName(temp_name, temp_name, MAX_PATH); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // it to pending_paths_ so we scan it after we finish scanning this | 686 // it to pending_paths_ so we scan it after we finish scanning this |
| 682 // directory. | 687 // directory. |
| 683 pending_paths_.push(cur_file); | 688 pending_paths_.push(cur_file); |
| 684 } | 689 } |
| 685 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); | 690 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); |
| 686 } | 691 } |
| 687 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); | 692 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); |
| 688 } | 693 } |
| 689 | 694 |
| 690 } // namespace file_util | 695 } // namespace file_util |
| OLD | NEW |