| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 412 |
| 413 if (count == 50) { | 413 if (count == 50) { |
| 414 return false; | 414 return false; |
| 415 } | 415 } |
| 416 | 416 |
| 417 new_temp_path->assign(path_to_create); | 417 new_temp_path->assign(path_to_create); |
| 418 return true; | 418 return true; |
| 419 } | 419 } |
| 420 | 420 |
| 421 bool CreateDirectory(const std::wstring& full_path) { | 421 bool CreateDirectory(const std::wstring& full_path) { |
| 422 if (PathExists(full_path)) |
| 423 return true; |
| 422 int err = SHCreateDirectoryEx(NULL, full_path.c_str(), NULL); | 424 int err = SHCreateDirectoryEx(NULL, full_path.c_str(), NULL); |
| 423 return err == ERROR_SUCCESS; | 425 return err == ERROR_SUCCESS; |
| 424 } | 426 } |
| 425 | 427 |
| 426 bool GetFileSize(const std::wstring& file_path, int64* file_size) { | 428 bool GetFileSize(const std::wstring& file_path, int64* file_size) { |
| 427 ScopedHandle file_handle( | 429 ScopedHandle file_handle( |
| 428 CreateFile(file_path.c_str(), GENERIC_READ, | 430 CreateFile(file_path.c_str(), GENERIC_READ, |
| 429 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, | 431 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, |
| 430 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); | 432 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); |
| 431 | 433 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); | 638 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); |
| 637 } | 639 } |
| 638 | 640 |
| 639 if ((file_type_ & FileEnumerator::DIRECTORIES) == 0) | 641 if ((file_type_ & FileEnumerator::DIRECTORIES) == 0) |
| 640 return Next(); | 642 return Next(); |
| 641 } | 643 } |
| 642 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); | 644 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); |
| 643 } | 645 } |
| 644 | 646 |
| 645 } // namespace file_util | 647 } // namespace file_util |
| 646 | |
| OLD | NEW |