| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <propvarutil.h> | 8 #include <propvarutil.h> |
| 9 #include <psapi.h> | 9 #include <psapi.h> |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <time.h> | 12 #include <time.h> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/pe_image.h" | 17 #include "base/pe_image.h" |
| 18 #include "base/scoped_comptr_win.h" | 18 #include "base/scoped_comptr_win.h" |
| 19 #include "base/scoped_handle.h" | 19 #include "base/scoped_handle.h" |
| 20 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 21 #include "base/time.h" | 22 #include "base/time.h" |
| 22 #include "base/win_util.h" | 23 #include "base/win_util.h" |
| 23 | 24 |
| 24 namespace file_util { | 25 namespace file_util { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // Helper for NormalizeFilePath(), defined below. | 29 // Helper for NormalizeFilePath(), defined below. |
| 29 bool DevicePathToDriveLetterPath(const FilePath& device_path, | 30 bool DevicePathToDriveLetterPath(const FilePath& device_path, |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 FilePath* new_dir) { | 556 FilePath* new_dir) { |
| 556 FilePath path_to_create; | 557 FilePath path_to_create; |
| 557 srand(static_cast<uint32>(time(NULL))); | 558 srand(static_cast<uint32>(time(NULL))); |
| 558 | 559 |
| 559 int count = 0; | 560 int count = 0; |
| 560 while (count < 50) { | 561 while (count < 50) { |
| 561 // Try create a new temporary directory with random generated name. If | 562 // Try create a new temporary directory with random generated name. If |
| 562 // the one exists, keep trying another path name until we reach some limit. | 563 // the one exists, keep trying another path name until we reach some limit. |
| 563 path_to_create = base_dir; | 564 path_to_create = base_dir; |
| 564 | 565 |
| 565 std::wstring new_dir_name; | 566 string16 new_dir_name; |
| 566 new_dir_name.assign(prefix); | 567 new_dir_name.assign(prefix); |
| 567 new_dir_name.append(IntToWString(rand() % kint16max)); | 568 new_dir_name.append(base::IntToString16(rand() % kint16max)); |
| 568 | 569 |
| 569 path_to_create = path_to_create.Append(new_dir_name); | 570 path_to_create = path_to_create.Append(new_dir_name); |
| 570 if (::CreateDirectory(path_to_create.value().c_str(), NULL)) | 571 if (::CreateDirectory(path_to_create.value().c_str(), NULL)) |
| 571 break; | 572 break; |
| 572 count++; | 573 count++; |
| 573 } | 574 } |
| 574 | 575 |
| 575 if (count == 50) { | 576 if (count == 50) { |
| 576 return false; | 577 return false; |
| 577 } | 578 } |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 size_t offset = 0; | 1054 size_t offset = 0; |
| 1054 while (offset < actual_size_to_read) { | 1055 while (offset < actual_size_to_read) { |
| 1055 uint8 unused = *(touch + offset); | 1056 uint8 unused = *(touch + offset); |
| 1056 offset += step_size; | 1057 offset += step_size; |
| 1057 } | 1058 } |
| 1058 FreeLibrary(dll_module); | 1059 FreeLibrary(dll_module); |
| 1059 return true; | 1060 return true; |
| 1060 } | 1061 } |
| 1061 | 1062 |
| 1062 } // namespace file_util | 1063 } // namespace file_util |
| OLD | NEW |