| 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 // 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 #pragma once | 10 #pragma once |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 public: | 416 public: |
| 417 #if defined(OS_WIN) | 417 #if defined(OS_WIN) |
| 418 typedef WIN32_FIND_DATA FindInfo; | 418 typedef WIN32_FIND_DATA FindInfo; |
| 419 #elif defined(OS_POSIX) | 419 #elif defined(OS_POSIX) |
| 420 typedef struct { | 420 typedef struct { |
| 421 struct stat stat; | 421 struct stat stat; |
| 422 std::string filename; | 422 std::string filename; |
| 423 } FindInfo; | 423 } FindInfo; |
| 424 #endif | 424 #endif |
| 425 | 425 |
| 426 enum FILE_TYPE { | 426 enum FileType { |
| 427 FILES = 1 << 0, | 427 FILES = 1 << 0, |
| 428 DIRECTORIES = 1 << 1, | 428 DIRECTORIES = 1 << 1, |
| 429 INCLUDE_DOT_DOT = 1 << 2, | 429 INCLUDE_DOT_DOT = 1 << 2, |
| 430 #if defined(OS_POSIX) | 430 #if defined(OS_POSIX) |
| 431 SHOW_SYM_LINKS = 1 << 4, | 431 SHOW_SYM_LINKS = 1 << 4, |
| 432 #endif | 432 #endif |
| 433 }; | 433 }; |
| 434 | 434 |
| 435 // |root_path| is the starting directory to search for. It may or may not end | 435 // |root_path| is the starting directory to search for. It may or may not end |
| 436 // in a slash. | 436 // in a slash. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 447 // works like shell globbing. For example, "*.txt" or "Foo???.doc". | 447 // works like shell globbing. For example, "*.txt" or "Foo???.doc". |
| 448 // However, be careful in specifying patterns that aren't cross platform | 448 // However, be careful in specifying patterns that aren't cross platform |
| 449 // since the underlying code uses OS-specific matching routines. In general, | 449 // since the underlying code uses OS-specific matching routines. In general, |
| 450 // Windows matching is less featureful than others, so test there first. | 450 // Windows matching is less featureful than others, so test there first. |
| 451 // If unspecified, this will match all files. | 451 // If unspecified, this will match all files. |
| 452 // NOTE: the pattern only matches the contents of root_path, not files in | 452 // NOTE: the pattern only matches the contents of root_path, not files in |
| 453 // recursive subdirectories. | 453 // recursive subdirectories. |
| 454 // TODO(erikkay): Fix the pattern matching to work at all levels. | 454 // TODO(erikkay): Fix the pattern matching to work at all levels. |
| 455 FileEnumerator(const FilePath& root_path, | 455 FileEnumerator(const FilePath& root_path, |
| 456 bool recursive, | 456 bool recursive, |
| 457 FileEnumerator::FILE_TYPE file_type); | 457 FileType file_type); |
| 458 FileEnumerator(const FilePath& root_path, | 458 FileEnumerator(const FilePath& root_path, |
| 459 bool recursive, | 459 bool recursive, |
| 460 FileEnumerator::FILE_TYPE file_type, | 460 FileType file_type, |
| 461 const FilePath::StringType& pattern); | 461 const FilePath::StringType& pattern); |
| 462 ~FileEnumerator(); | 462 ~FileEnumerator(); |
| 463 | 463 |
| 464 // Returns an empty string if there are no more results. | 464 // Returns an empty string if there are no more results. |
| 465 FilePath Next(); | 465 FilePath Next(); |
| 466 | 466 |
| 467 // Write the file info into |info|. | 467 // Write the file info into |info|. |
| 468 void GetFindInfo(FindInfo* info); | 468 void GetFindInfo(FindInfo* info); |
| 469 | 469 |
| 470 // Looks inside a FindInfo and determines if it's a directory. | 470 // Looks inside a FindInfo and determines if it's a directory. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 496 | 496 |
| 497 // The files in the current directory | 497 // The files in the current directory |
| 498 std::vector<DirectoryEntryInfo> directory_entries_; | 498 std::vector<DirectoryEntryInfo> directory_entries_; |
| 499 | 499 |
| 500 // The next entry to use from the directory_entries_ vector | 500 // The next entry to use from the directory_entries_ vector |
| 501 size_t current_directory_entry_; | 501 size_t current_directory_entry_; |
| 502 #endif | 502 #endif |
| 503 | 503 |
| 504 FilePath root_path_; | 504 FilePath root_path_; |
| 505 bool recursive_; | 505 bool recursive_; |
| 506 FILE_TYPE file_type_; | 506 FileType file_type_; |
| 507 FilePath::StringType pattern_; // Empty when we want to find everything. | 507 FilePath::StringType pattern_; // Empty when we want to find everything. |
| 508 | 508 |
| 509 // A stack that keeps track of which subdirectories we still need to | 509 // A stack that keeps track of which subdirectories we still need to |
| 510 // enumerate in the breadth-first search. | 510 // enumerate in the breadth-first search. |
| 511 std::stack<FilePath> pending_paths_; | 511 std::stack<FilePath> pending_paths_; |
| 512 | 512 |
| 513 DISALLOW_COPY_AND_ASSIGN(FileEnumerator); | 513 DISALLOW_COPY_AND_ASSIGN(FileEnumerator); |
| 514 }; | 514 }; |
| 515 | 515 |
| 516 class BASE_EXPORT MemoryMappedFile { | 516 class BASE_EXPORT MemoryMappedFile { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 659 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
| 660 #endif | 660 #endif |
| 661 | 661 |
| 662 } // namespace file_util | 662 } // namespace file_util |
| 663 | 663 |
| 664 // Deprecated functions have been moved to this separate header file, | 664 // Deprecated functions have been moved to this separate header file, |
| 665 // which must be included last after all the above definitions. | 665 // which must be included last after all the above definitions. |
| 666 #include "base/file_util_deprecated.h" | 666 #include "base/file_util_deprecated.h" |
| 667 | 667 |
| 668 #endif // BASE_FILE_UTIL_H_ | 668 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |