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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 }; | 510 }; |
511 | 511 |
512 // |root_path| is the starting directory to search for. It may or may not end | 512 // |root_path| is the starting directory to search for. It may or may not end |
513 // in a slash. | 513 // in a slash. |
514 // | 514 // |
515 // If |recursive| is true, this will enumerate all matches in any | 515 // If |recursive| is true, this will enumerate all matches in any |
516 // subdirectories matched as well. It does a breadth-first search, so all | 516 // subdirectories matched as well. It does a breadth-first search, so all |
517 // files in one directory will be returned before any files in a | 517 // files in one directory will be returned before any files in a |
518 // subdirectory. | 518 // subdirectory. |
519 // | 519 // |
520 // |file_type| specifies whether the enumerator should match files, | 520 // |file_type| specifies whether the enumerator should match files, |
satorux1
2012/08/06 06:09:01
What about:
|file_type|, a bit mask of |FileType
Haruki Sato
2012/08/06 23:22:18
Done.
Thanks.
| |
521 // directories, or both. | 521 // directories, or both. |
522 // | 522 // |
523 // |pattern| is an optional pattern for which files to match. This | 523 // |pattern| is an optional pattern for which files to match. This |
524 // works like shell globbing. For example, "*.txt" or "Foo???.doc". | 524 // works like shell globbing. For example, "*.txt" or "Foo???.doc". |
525 // However, be careful in specifying patterns that aren't cross platform | 525 // However, be careful in specifying patterns that aren't cross platform |
526 // since the underlying code uses OS-specific matching routines. In general, | 526 // since the underlying code uses OS-specific matching routines. In general, |
527 // Windows matching is less featureful than others, so test there first. | 527 // Windows matching is less featureful than others, so test there first. |
528 // If unspecified, this will match all files. | 528 // If unspecified, this will match all files. |
529 // NOTE: the pattern only matches the contents of root_path, not files in | 529 // NOTE: the pattern only matches the contents of root_path, not files in |
530 // recursive subdirectories. | 530 // recursive subdirectories. |
531 // TODO(erikkay): Fix the pattern matching to work at all levels. | 531 // TODO(erikkay): Fix the pattern matching to work at all levels. |
532 FileEnumerator(const FilePath& root_path, | 532 FileEnumerator(const FilePath& root_path, |
533 bool recursive, | 533 bool recursive, |
534 FileType file_type); | 534 int file_type); |
535 FileEnumerator(const FilePath& root_path, | 535 FileEnumerator(const FilePath& root_path, |
536 bool recursive, | 536 bool recursive, |
537 FileType file_type, | 537 int file_type, |
538 const FilePath::StringType& pattern); | 538 const FilePath::StringType& pattern); |
539 ~FileEnumerator(); | 539 ~FileEnumerator(); |
540 | 540 |
541 // Returns an empty string if there are no more results. | 541 // Returns an empty string if there are no more results. |
542 FilePath Next(); | 542 FilePath Next(); |
543 | 543 |
544 // Write the file info into |info|. | 544 // Write the file info into |info|. |
545 void GetFindInfo(FindInfo* info); | 545 void GetFindInfo(FindInfo* info); |
546 | 546 |
547 // Looks inside a FindInfo and determines if it's a directory. | 547 // Looks inside a FindInfo and determines if it's a directory. |
(...skipping 26 matching lines...) Expand all Loading... | |
574 | 574 |
575 // The files in the current directory | 575 // The files in the current directory |
576 std::vector<DirectoryEntryInfo> directory_entries_; | 576 std::vector<DirectoryEntryInfo> directory_entries_; |
577 | 577 |
578 // The next entry to use from the directory_entries_ vector | 578 // The next entry to use from the directory_entries_ vector |
579 size_t current_directory_entry_; | 579 size_t current_directory_entry_; |
580 #endif | 580 #endif |
581 | 581 |
582 FilePath root_path_; | 582 FilePath root_path_; |
583 bool recursive_; | 583 bool recursive_; |
584 FileType file_type_; | 584 int file_type_; |
585 FilePath::StringType pattern_; // Empty when we want to find everything. | 585 FilePath::StringType pattern_; // Empty when we want to find everything. |
586 | 586 |
587 // A stack that keeps track of which subdirectories we still need to | 587 // A stack that keeps track of which subdirectories we still need to |
588 // enumerate in the breadth-first search. | 588 // enumerate in the breadth-first search. |
589 std::stack<FilePath> pending_paths_; | 589 std::stack<FilePath> pending_paths_; |
590 | 590 |
591 DISALLOW_COPY_AND_ASSIGN(FileEnumerator); | 591 DISALLOW_COPY_AND_ASSIGN(FileEnumerator); |
592 }; | 592 }; |
593 | 593 |
594 class BASE_EXPORT MemoryMappedFile { | 594 class BASE_EXPORT MemoryMappedFile { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 }; | 665 }; |
666 | 666 |
667 // Attempts determine the FileSystemType for |path|. | 667 // Attempts determine the FileSystemType for |path|. |
668 // Returns false if |path| doesn't exist. | 668 // Returns false if |path| doesn't exist. |
669 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 669 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
670 #endif | 670 #endif |
671 | 671 |
672 } // namespace file_util | 672 } // namespace file_util |
673 | 673 |
674 #endif // BASE_FILE_UTIL_H_ | 674 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |