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 "chrome/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 Extension::kLocaleFolder, | 644 Extension::kLocaleFolder, |
645 FILE_PATH_LITERAL("__MACOSX"), | 645 FILE_PATH_LITERAL("__MACOSX"), |
646 }; | 646 }; |
647 CR_DEFINE_STATIC_LOCAL( | 647 CR_DEFINE_STATIC_LOCAL( |
648 std::set<FilePath::StringType>, reserved_underscore_names, | 648 std::set<FilePath::StringType>, reserved_underscore_names, |
649 (reserved_names, reserved_names + arraysize(reserved_names))); | 649 (reserved_names, reserved_names + arraysize(reserved_names))); |
650 | 650 |
651 // Enumerate all files and directories in the extension root. | 651 // Enumerate all files and directories in the extension root. |
652 // There is a problem when using pattern "_*" with FileEnumerator, so we have | 652 // There is a problem when using pattern "_*" with FileEnumerator, so we have |
653 // to cheat with find_first_of and match all. | 653 // to cheat with find_first_of and match all. |
| 654 const int kFilesAndDirectories = |
| 655 file_util::FileEnumerator::DIRECTORIES | file_util::FileEnumerator::FILES; |
654 file_util::FileEnumerator all_files( | 656 file_util::FileEnumerator all_files( |
655 extension_path, | 657 extension_path, false, kFilesAndDirectories); |
656 false, | |
657 static_cast<file_util::FileEnumerator::FileType>( | |
658 file_util::FileEnumerator::DIRECTORIES | | |
659 file_util::FileEnumerator::FILES)); | |
660 | 658 |
661 FilePath file; | 659 FilePath file; |
662 while (!(file = all_files.Next()).empty()) { | 660 while (!(file = all_files.Next()).empty()) { |
663 FilePath::StringType filename = file.BaseName().value(); | 661 FilePath::StringType filename = file.BaseName().value(); |
664 // Skip all that don't start with "_". | 662 // Skip all that don't start with "_". |
665 if (filename.find_first_of(FILE_PATH_LITERAL("_")) != 0) continue; | 663 if (filename.find_first_of(FILE_PATH_LITERAL("_")) != 0) continue; |
666 if (reserved_underscore_names.find(filename) == | 664 if (reserved_underscore_names.find(filename) == |
667 reserved_underscore_names.end()) { | 665 reserved_underscore_names.end()) { |
668 *error = base::StringPrintf( | 666 *error = base::StringPrintf( |
669 "Cannot load extension with file or directory name %s. " | 667 "Cannot load extension with file or directory name %s. " |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 return temp_path; | 786 return temp_path; |
789 | 787 |
790 return FilePath(); | 788 return FilePath(); |
791 } | 789 } |
792 | 790 |
793 void DeleteFile(const FilePath& path, bool recursive) { | 791 void DeleteFile(const FilePath& path, bool recursive) { |
794 file_util::Delete(path, recursive); | 792 file_util::Delete(path, recursive); |
795 } | 793 } |
796 | 794 |
797 } // namespace extension_file_util | 795 } // namespace extension_file_util |
OLD | NEW |