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 // This file contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
6 // filesystem. | 6 // filesystem. |
7 | 7 |
8 #ifndef BASE_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
10 | 10 |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 }; | 516 }; |
517 | 517 |
518 // |root_path| is the starting directory to search for. It may or may not end | 518 // |root_path| is the starting directory to search for. It may or may not end |
519 // in a slash. | 519 // in a slash. |
520 // | 520 // |
521 // If |recursive| is true, this will enumerate all matches in any | 521 // If |recursive| is true, this will enumerate all matches in any |
522 // subdirectories matched as well. It does a breadth-first search, so all | 522 // subdirectories matched as well. It does a breadth-first search, so all |
523 // files in one directory will be returned before any files in a | 523 // files in one directory will be returned before any files in a |
524 // subdirectory. | 524 // subdirectory. |
525 // | 525 // |
526 // |file_type| specifies whether the enumerator should match files, | 526 // |file_type|, a bit mask of FileType, specifies whether the enumerator |
527 // directories, or both. | 527 // should match files, directories, or both. |
528 // | 528 // |
529 // |pattern| is an optional pattern for which files to match. This | 529 // |pattern| is an optional pattern for which files to match. This |
530 // works like shell globbing. For example, "*.txt" or "Foo???.doc". | 530 // works like shell globbing. For example, "*.txt" or "Foo???.doc". |
531 // However, be careful in specifying patterns that aren't cross platform | 531 // However, be careful in specifying patterns that aren't cross platform |
532 // since the underlying code uses OS-specific matching routines. In general, | 532 // since the underlying code uses OS-specific matching routines. In general, |
533 // Windows matching is less featureful than others, so test there first. | 533 // Windows matching is less featureful than others, so test there first. |
534 // If unspecified, this will match all files. | 534 // If unspecified, this will match all files. |
535 // NOTE: the pattern only matches the contents of root_path, not files in | 535 // NOTE: the pattern only matches the contents of root_path, not files in |
536 // recursive subdirectories. | 536 // recursive subdirectories. |
537 // TODO(erikkay): Fix the pattern matching to work at all levels. | 537 // TODO(erikkay): Fix the pattern matching to work at all levels. |
538 FileEnumerator(const FilePath& root_path, | 538 FileEnumerator(const FilePath& root_path, |
539 bool recursive, | 539 bool recursive, |
540 FileType file_type); | 540 int file_type); |
541 FileEnumerator(const FilePath& root_path, | 541 FileEnumerator(const FilePath& root_path, |
542 bool recursive, | 542 bool recursive, |
543 FileType file_type, | 543 int file_type, |
544 const FilePath::StringType& pattern); | 544 const FilePath::StringType& pattern); |
545 ~FileEnumerator(); | 545 ~FileEnumerator(); |
546 | 546 |
547 // Returns an empty string if there are no more results. | 547 // Returns an empty string if there are no more results. |
548 FilePath Next(); | 548 FilePath Next(); |
549 | 549 |
550 // Write the file info into |info|. | 550 // Write the file info into |info|. |
551 void GetFindInfo(FindInfo* info); | 551 void GetFindInfo(FindInfo* info); |
552 | 552 |
553 // Looks inside a FindInfo and determines if it's a directory. | 553 // Looks inside a FindInfo and determines if it's a directory. |
(...skipping 26 matching lines...) Expand all Loading... |
580 | 580 |
581 // The files in the current directory | 581 // The files in the current directory |
582 std::vector<DirectoryEntryInfo> directory_entries_; | 582 std::vector<DirectoryEntryInfo> directory_entries_; |
583 | 583 |
584 // The next entry to use from the directory_entries_ vector | 584 // The next entry to use from the directory_entries_ vector |
585 size_t current_directory_entry_; | 585 size_t current_directory_entry_; |
586 #endif | 586 #endif |
587 | 587 |
588 FilePath root_path_; | 588 FilePath root_path_; |
589 bool recursive_; | 589 bool recursive_; |
590 FileType file_type_; | 590 int file_type_; |
591 FilePath::StringType pattern_; // Empty when we want to find everything. | 591 FilePath::StringType pattern_; // Empty when we want to find everything. |
592 | 592 |
593 // A stack that keeps track of which subdirectories we still need to | 593 // A stack that keeps track of which subdirectories we still need to |
594 // enumerate in the breadth-first search. | 594 // enumerate in the breadth-first search. |
595 std::stack<FilePath> pending_paths_; | 595 std::stack<FilePath> pending_paths_; |
596 | 596 |
597 DISALLOW_COPY_AND_ASSIGN(FileEnumerator); | 597 DISALLOW_COPY_AND_ASSIGN(FileEnumerator); |
598 }; | 598 }; |
599 | 599 |
600 class BASE_EXPORT MemoryMappedFile { | 600 class BASE_EXPORT MemoryMappedFile { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 }; | 671 }; |
672 | 672 |
673 // Attempts determine the FileSystemType for |path|. | 673 // Attempts determine the FileSystemType for |path|. |
674 // Returns false if |path| doesn't exist. | 674 // Returns false if |path| doesn't exist. |
675 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 675 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
676 #endif | 676 #endif |
677 | 677 |
678 } // namespace file_util | 678 } // namespace file_util |
679 | 679 |
680 #endif // BASE_FILE_UTIL_H_ | 680 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |