OLD | NEW |
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 <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 if (!DirectoryExists(*i)) | 535 if (!DirectoryExists(*i)) |
536 return false; | 536 return false; |
537 } | 537 } |
538 return true; | 538 return true; |
539 } | 539 } |
540 | 540 |
541 base::FilePath MakeUniqueDirectory(const base::FilePath& path) { | 541 base::FilePath MakeUniqueDirectory(const base::FilePath& path) { |
542 const int kMaxAttempts = 20; | 542 const int kMaxAttempts = 20; |
543 for (int attempts = 0; attempts < kMaxAttempts; attempts++) { | 543 for (int attempts = 0; attempts < kMaxAttempts; attempts++) { |
544 int uniquifier = | 544 int uniquifier = |
545 GetUniquePathNumber(path, FILE_PATH_LITERAL(std::string())); | 545 GetUniquePathNumber(path, base::FilePath::StringType()); |
546 if (uniquifier < 0) | 546 if (uniquifier < 0) |
547 break; | 547 break; |
548 base::FilePath test_path = (uniquifier == 0) ? path : | 548 base::FilePath test_path = (uniquifier == 0) ? path : |
549 path.InsertBeforeExtensionASCII( | 549 path.InsertBeforeExtensionASCII( |
550 base::StringPrintf(" (%d)", uniquifier)); | 550 base::StringPrintf(" (%d)", uniquifier)); |
551 if (mkdir(test_path.value().c_str(), 0777) == 0) | 551 if (mkdir(test_path.value().c_str(), 0777) == 0) |
552 return test_path; | 552 return test_path; |
553 else if (errno != EEXIST) | 553 else if (errno != EEXIST) |
554 break; | 554 break; |
555 } | 555 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 kFileSystemRoot, path, kRootUid, allowed_group_ids); | 1056 kFileSystemRoot, path, kRootUid, allowed_group_ids); |
1057 } | 1057 } |
1058 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1058 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
1059 | 1059 |
1060 int GetMaximumPathComponentLength(const FilePath& path) { | 1060 int GetMaximumPathComponentLength(const FilePath& path) { |
1061 base::ThreadRestrictions::AssertIOAllowed(); | 1061 base::ThreadRestrictions::AssertIOAllowed(); |
1062 return pathconf(path.value().c_str(), _PC_NAME_MAX); | 1062 return pathconf(path.value().c_str(), _PC_NAME_MAX); |
1063 } | 1063 } |
1064 | 1064 |
1065 } // namespace file_util | 1065 } // namespace file_util |
OLD | NEW |