OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 const FilePath::StringType& prefix, | 599 const FilePath::StringType& prefix, |
600 FilePath* new_dir) { | 600 FilePath* new_dir) { |
601 base::ThreadRestrictions::AssertIOAllowed(); | 601 base::ThreadRestrictions::AssertIOAllowed(); |
602 | 602 |
603 FilePath path_to_create; | 603 FilePath path_to_create; |
604 srand(static_cast<uint32>(time(NULL))); | 604 srand(static_cast<uint32>(time(NULL))); |
605 | 605 |
606 for (int count = 0; count < 50; ++count) { | 606 for (int count = 0; count < 50; ++count) { |
607 // Try create a new temporary directory with random generated name. If | 607 // Try create a new temporary directory with random generated name. If |
608 // the one exists, keep trying another path name until we reach some limit. | 608 // the one exists, keep trying another path name until we reach some limit. |
609 path_to_create = base_dir; | |
610 | |
611 string16 new_dir_name; | 609 string16 new_dir_name; |
612 new_dir_name.assign(prefix); | 610 new_dir_name.assign(prefix); |
613 new_dir_name.append(base::IntToString16(rand() % kint16max)); | 611 new_dir_name.append(base::IntToString16(rand() % kint16max)); |
614 | 612 |
615 path_to_create = path_to_create.Append(new_dir_name); | 613 path_to_create = base_dir.Append(new_dir_name); |
616 if (::CreateDirectory(path_to_create.value().c_str(), NULL)) { | 614 if (::CreateDirectory(path_to_create.value().c_str(), NULL)) { |
617 *new_dir = path_to_create; | 615 *new_dir = path_to_create; |
618 return true; | 616 return true; |
619 } | 617 } |
620 } | 618 } |
621 | 619 |
622 return false; | 620 return false; |
623 } | 621 } |
624 | 622 |
625 bool CreateNewTempDirectory(const FilePath::StringType& prefix, | 623 bool CreateNewTempDirectory(const FilePath::StringType& prefix, |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 uint8 unused = *(touch + offset); | 1117 uint8 unused = *(touch + offset); |
1120 offset += step_size; | 1118 offset += step_size; |
1121 } | 1119 } |
1122 FreeLibrary(dll_module); | 1120 FreeLibrary(dll_module); |
1123 } | 1121 } |
1124 | 1122 |
1125 return true; | 1123 return true; |
1126 } | 1124 } |
1127 | 1125 |
1128 } // namespace file_util | 1126 } // namespace file_util |
OLD | NEW |