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 "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_util.h" | 10 #include "base/file_util.h" |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 }; | 490 }; |
491 static std::set<FilePath::StringType> reserved_underscore_names( | 491 static std::set<FilePath::StringType> reserved_underscore_names( |
492 reserved_names, reserved_names + arraysize(reserved_names)); | 492 reserved_names, reserved_names + arraysize(reserved_names)); |
493 | 493 |
494 // Enumerate all files and directories in the extension root. | 494 // Enumerate all files and directories in the extension root. |
495 // There is a problem when using pattern "_*" with FileEnumerator, so we have | 495 // There is a problem when using pattern "_*" with FileEnumerator, so we have |
496 // to cheat with find_first_of and match all. | 496 // to cheat with find_first_of and match all. |
497 file_util::FileEnumerator all_files( | 497 file_util::FileEnumerator all_files( |
498 extension_path, | 498 extension_path, |
499 false, | 499 false, |
500 static_cast<file_util::FileEnumerator::FILE_TYPE>( | 500 static_cast<file_util::FileEnumerator::FileType>( |
501 file_util::FileEnumerator::DIRECTORIES | | 501 file_util::FileEnumerator::DIRECTORIES | |
502 file_util::FileEnumerator::FILES)); | 502 file_util::FileEnumerator::FILES)); |
503 | 503 |
504 FilePath file; | 504 FilePath file; |
505 while (!(file = all_files.Next()).empty()) { | 505 while (!(file = all_files.Next()).empty()) { |
506 FilePath::StringType filename = file.BaseName().value(); | 506 FilePath::StringType filename = file.BaseName().value(); |
507 // Skip all that don't start with "_". | 507 // Skip all that don't start with "_". |
508 if (filename.find_first_of(FILE_PATH_LITERAL("_")) != 0) continue; | 508 if (filename.find_first_of(FILE_PATH_LITERAL("_")) != 0) continue; |
509 if (reserved_underscore_names.find(filename) == | 509 if (reserved_underscore_names.find(filename) == |
510 reserved_underscore_names.end()) { | 510 reserved_underscore_names.end()) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 return temp_path; | 614 return temp_path; |
615 | 615 |
616 return FilePath(); | 616 return FilePath(); |
617 } | 617 } |
618 | 618 |
619 void DeleteFile(const FilePath& path, bool recursive) { | 619 void DeleteFile(const FilePath& path, bool recursive) { |
620 file_util::Delete(path, recursive); | 620 file_util::Delete(path, recursive); |
621 } | 621 } |
622 | 622 |
623 } // namespace extension_file_util | 623 } // namespace extension_file_util |
OLD | NEW |