diff options
109 files changed, 913 insertions, 974 deletions
diff --git a/base/base.gypi b/base/base.gypi index be869ce..7194f24 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -159,10 +159,6 @@ 'files/dir_reader_fallback.h', 'files/dir_reader_linux.h', 'files/dir_reader_posix.h', - 'files/file_enumerator.cc', - 'files/file_enumerator.h', - 'files/file_enumerator_posix.cc', - 'files/file_enumerator_win.cc', 'files/file_path.cc', 'files/file_path.h', 'files/file_path_watcher.cc', @@ -633,7 +629,6 @@ 'file_util.cc', 'file_util_posix.cc', 'file_util_proxy.cc', - 'files/file_enumerator_posix.cc', 'files/file_path_watcher_kqueue.cc', 'memory/shared_memory_posix.cc', 'native_library_posix.cc', diff --git a/base/file_util.cc b/base/file_util.cc index 8cdf75b..e76c5c2 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -11,7 +11,6 @@ #include <fstream> -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/string_util.h" @@ -19,7 +18,6 @@ #include "base/strings/string_piece.h" #include "base/utf_string_conversions.h" -using base::FileEnumerator; using base::FilePath; namespace { @@ -167,7 +165,7 @@ bool ReadFileToString(const FilePath& path, std::string* contents) { bool IsDirectoryEmpty(const FilePath& dir_path) { FileEnumerator files(dir_path, false, FileEnumerator::FILES | FileEnumerator::DIRECTORIES); - if (files.Next().empty()) + if (files.Next().value().empty()) return true; return false; } @@ -264,9 +262,30 @@ int GetUniquePathNumber( int64 ComputeDirectorySize(const FilePath& root_path) { int64 running_size = 0; FileEnumerator file_iter(root_path, true, FileEnumerator::FILES); - while (!file_iter.Next().empty()) - running_size += file_iter.GetInfo().GetSize(); + for (FilePath current = file_iter.Next(); !current.empty(); + current = file_iter.Next()) { + FileEnumerator::FindInfo info; + file_iter.GetFindInfo(&info); +#if defined(OS_WIN) + LARGE_INTEGER li = { info.nFileSizeLow, info.nFileSizeHigh }; + running_size += li.QuadPart; +#else + running_size += info.stat.st_size; +#endif + } return running_size; } +/////////////////////////////////////////////// +// FileEnumerator +// +// Note: the main logic is in file_util_<platform>.cc + +bool FileEnumerator::ShouldSkip(const FilePath& path) { + FilePath::StringType basename = path.BaseName().value(); + return basename == FILE_PATH_LITERAL(".") || + (basename == FILE_PATH_LITERAL("..") && + !(INCLUDE_DOT_DOT & file_type_)); +} + } // namespace diff --git a/base/file_util.h b/base/file_util.h index b9bb6eb..4ffd05b 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -20,6 +20,7 @@ #include <stdio.h> #include <set> +#include <stack> #include <string> #include <vector> @@ -116,9 +117,9 @@ BASE_EXPORT bool CopyFileUnsafe(const base::FilePath& from_path, // Copies the given path, and optionally all subdirectories and their contents // as well. -// -// If there are files existing under to_path, always overwrite. Returns true -// if successful, false otherwise. Wildcards on the names are not supported. +// If there are files existing under to_path, always overwrite. +// Returns true if successful, false otherwise. +// Don't use wildcards on the names, it may stop working without notice. // // If you only need to copy a file use CopyFile, it's faster. BASE_EXPORT bool CopyDirectory(const base::FilePath& from_path, @@ -421,6 +422,113 @@ class ScopedFDClose { typedef scoped_ptr_malloc<int, ScopedFDClose> ScopedFD; #endif // OS_POSIX +// A class for enumerating the files in a provided path. The order of the +// results is not guaranteed. +// +// DO NOT USE FROM THE MAIN THREAD of your application unless it is a test +// program where latency does not matter. This class is blocking. +class BASE_EXPORT FileEnumerator { + public: +#if defined(OS_WIN) + typedef WIN32_FIND_DATA FindInfo; +#elif defined(OS_POSIX) + typedef struct { + struct stat stat; + std::string filename; + } FindInfo; +#endif + + enum FileType { + FILES = 1 << 0, + DIRECTORIES = 1 << 1, + INCLUDE_DOT_DOT = 1 << 2, +#if defined(OS_POSIX) + SHOW_SYM_LINKS = 1 << 4, +#endif + }; + + // |root_path| is the starting directory to search for. It may or may not end + // in a slash. + // + // If |recursive| is true, this will enumerate all matches in any + // subdirectories matched as well. It does a breadth-first search, so all + // files in one directory will be returned before any files in a + // subdirectory. + // + // |file_type|, a bit mask of FileType, specifies whether the enumerator + // should match files, directories, or both. + // + // |pattern| is an optional pattern for which files to match. This + // works like shell globbing. For example, "*.txt" or "Foo???.doc". + // However, be careful in specifying patterns that aren't cross platform + // since the underlying code uses OS-specific matching routines. In general, + // Windows matching is less featureful than others, so test there first. + // If unspecified, this will match all files. + // NOTE: the pattern only matches the contents of root_path, not files in + // recursive subdirectories. + // TODO(erikkay): Fix the pattern matching to work at all levels. + FileEnumerator(const base::FilePath& root_path, + bool recursive, + int file_type); + FileEnumerator(const base::FilePath& root_path, + bool recursive, + int file_type, + const base::FilePath::StringType& pattern); + ~FileEnumerator(); + + // Returns an empty string if there are no more results. + base::FilePath Next(); + + // Write the file info into |info|. + void GetFindInfo(FindInfo* info); + + // Looks inside a FindInfo and determines if it's a directory. + static bool IsDirectory(const FindInfo& info); + + static base::FilePath GetFilename(const FindInfo& find_info); + static int64 GetFilesize(const FindInfo& find_info); + static base::Time GetLastModifiedTime(const FindInfo& find_info); + + private: + // Returns true if the given path should be skipped in enumeration. + bool ShouldSkip(const base::FilePath& path); + + +#if defined(OS_WIN) + // True when find_data_ is valid. + bool has_find_data_; + WIN32_FIND_DATA find_data_; + HANDLE find_handle_; +#elif defined(OS_POSIX) + struct DirectoryEntryInfo { + base::FilePath filename; + struct stat stat; + }; + + // Read the filenames in source into the vector of DirectoryEntryInfo's + static bool ReadDirectory(std::vector<DirectoryEntryInfo>* entries, + const base::FilePath& source, bool show_links); + + // The files in the current directory + std::vector<DirectoryEntryInfo> directory_entries_; + + // The next entry to use from the directory_entries_ vector + size_t current_directory_entry_; +#endif + + base::FilePath root_path_; + bool recursive_; + int file_type_; + base::FilePath::StringType pattern_; // Empty when we want to find + // everything. + + // A stack that keeps track of which subdirectories we still need to + // enumerate in the breadth-first search. + std::stack<base::FilePath> pending_paths_; + + DISALLOW_COPY_AND_ASSIGN(FileEnumerator); +}; + #if defined(OS_LINUX) // Broad categories of file systems as returned by statfs() on Linux. enum FileSystemType { diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 68516e4..8b36812 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -7,6 +7,7 @@ #include <dirent.h> #include <errno.h> #include <fcntl.h> +#include <fnmatch.h> #include <libgen.h> #include <limits.h> #include <stdio.h> @@ -31,7 +32,6 @@ #include <fstream> #include "base/basictypes.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -58,7 +58,6 @@ #include "base/chromeos/chromeos_version.h" #endif -using base::FileEnumerator; using base::FilePath; using base::MakeAbsoluteFilePath; @@ -191,7 +190,10 @@ bool Delete(const FilePath& path, bool recursive) { FileEnumerator::SHOW_SYM_LINKS); for (FilePath current = traversal.Next(); success && !current.empty(); current = traversal.Next()) { - if (traversal.GetInfo().IsDirectory()) + FileEnumerator::FindInfo info; + traversal.GetFindInfo(&info); + + if (S_ISDIR(info.stat.st_mode)) directories.push(current.value()); else success = (unlink(current.value().c_str()) == 0); @@ -235,13 +237,14 @@ bool ReplaceFile(const FilePath& from_path, const FilePath& to_path) { return (rename(from_path.value().c_str(), to_path.value().c_str()) == 0); } -bool CopyDirectory(const base::FilePath& from_path, - const base::FilePath& to_path, +bool CopyDirectory(const FilePath& from_path, + const FilePath& to_path, bool recursive) { base::ThreadRestrictions::AssertIOAllowed(); // Some old callers of CopyDirectory want it to support wildcards. // After some discussion, we decided to fix those callers. // Break loudly here if anyone tries to do this. + // TODO(evanm): remove this once we're sure it's ok. DCHECK(to_path.value().find('*') == std::string::npos); DCHECK(from_path.value().find('*') == std::string::npos); @@ -278,9 +281,9 @@ bool CopyDirectory(const base::FilePath& from_path, // We have to mimic windows behavior here. |to_path| may not exist yet, // start the loop with |to_path|. - struct stat from_stat; + FileEnumerator::FindInfo info; FilePath current = from_path; - if (stat(from_path.value().c_str(), &from_stat) < 0) { + if (stat(from_path.value().c_str(), &info.stat) < 0) { DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: " << from_path.value() << " errno = " << errno; success = false; @@ -296,7 +299,7 @@ bool CopyDirectory(const base::FilePath& from_path, // The Windows version of this function assumes that non-recursive calls // will always have a directory for from_path. - DCHECK(recursive || S_ISDIR(from_stat.st_mode)); + DCHECK(recursive || S_ISDIR(info.stat.st_mode)); while (success && !current.empty()) { // current is the source path, including from_path, so append @@ -309,14 +312,14 @@ bool CopyDirectory(const base::FilePath& from_path, } } - if (S_ISDIR(from_stat.st_mode)) { - if (mkdir(target_path.value().c_str(), from_stat.st_mode & 01777) != 0 && + if (S_ISDIR(info.stat.st_mode)) { + if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 && errno != EEXIST) { DLOG(ERROR) << "CopyDirectory() couldn't create directory: " << target_path.value() << " errno = " << errno; success = false; } - } else if (S_ISREG(from_stat.st_mode)) { + } else if (S_ISREG(info.stat.st_mode)) { if (!CopyFile(current, target_path)) { DLOG(ERROR) << "CopyDirectory() couldn't create file: " << target_path.value(); @@ -328,8 +331,7 @@ bool CopyDirectory(const base::FilePath& from_path, } current = traversal.Next(); - if (!current.empty()) - from_stat = traversal.GetInfo().stat(); + traversal.GetFindInfo(&info); } return success; @@ -682,6 +684,156 @@ bool SetCurrentDirectory(const FilePath& path) { return !ret; } +/////////////////////////////////////////////// +// FileEnumerator + +FileEnumerator::FileEnumerator(const FilePath& root_path, + bool recursive, + int file_type) + : current_directory_entry_(0), + root_path_(root_path), + recursive_(recursive), + file_type_(file_type) { + // INCLUDE_DOT_DOT must not be specified if recursive. + DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); + pending_paths_.push(root_path); +} + +FileEnumerator::FileEnumerator(const FilePath& root_path, + bool recursive, + int file_type, + const FilePath::StringType& pattern) + : current_directory_entry_(0), + root_path_(root_path), + recursive_(recursive), + file_type_(file_type), + pattern_(root_path.Append(pattern).value()) { + // INCLUDE_DOT_DOT must not be specified if recursive. + DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); + // The Windows version of this code appends the pattern to the root_path, + // potentially only matching against items in the top-most directory. + // Do the same here. + if (pattern.empty()) + pattern_ = FilePath::StringType(); + pending_paths_.push(root_path); +} + +FileEnumerator::~FileEnumerator() { +} + +FilePath FileEnumerator::Next() { + ++current_directory_entry_; + + // While we've exhausted the entries in the current directory, do the next + while (current_directory_entry_ >= directory_entries_.size()) { + if (pending_paths_.empty()) + return FilePath(); + + root_path_ = pending_paths_.top(); + root_path_ = root_path_.StripTrailingSeparators(); + pending_paths_.pop(); + + std::vector<DirectoryEntryInfo> entries; + if (!ReadDirectory(&entries, root_path_, file_type_ & SHOW_SYM_LINKS)) + continue; + + directory_entries_.clear(); + current_directory_entry_ = 0; + for (std::vector<DirectoryEntryInfo>::const_iterator + i = entries.begin(); i != entries.end(); ++i) { + FilePath full_path = root_path_.Append(i->filename); + if (ShouldSkip(full_path)) + continue; + + if (pattern_.size() && + fnmatch(pattern_.c_str(), full_path.value().c_str(), FNM_NOESCAPE)) + continue; + + if (recursive_ && S_ISDIR(i->stat.st_mode)) + pending_paths_.push(full_path); + + if ((S_ISDIR(i->stat.st_mode) && (file_type_ & DIRECTORIES)) || + (!S_ISDIR(i->stat.st_mode) && (file_type_ & FILES))) + directory_entries_.push_back(*i); + } + } + + return root_path_.Append(directory_entries_[current_directory_entry_ + ].filename); +} + +void FileEnumerator::GetFindInfo(FindInfo* info) { + DCHECK(info); + + if (current_directory_entry_ >= directory_entries_.size()) + return; + + DirectoryEntryInfo* cur_entry = &directory_entries_[current_directory_entry_]; + memcpy(&(info->stat), &(cur_entry->stat), sizeof(info->stat)); + info->filename.assign(cur_entry->filename.value()); +} + +// static +bool FileEnumerator::IsDirectory(const FindInfo& info) { + return S_ISDIR(info.stat.st_mode); +} + +// static +FilePath FileEnumerator::GetFilename(const FindInfo& find_info) { + return FilePath(find_info.filename); +} + +// static +int64 FileEnumerator::GetFilesize(const FindInfo& find_info) { + return find_info.stat.st_size; +} + +// static +base::Time FileEnumerator::GetLastModifiedTime(const FindInfo& find_info) { + return base::Time::FromTimeT(find_info.stat.st_mtime); +} + +bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries, + const FilePath& source, bool show_links) { + base::ThreadRestrictions::AssertIOAllowed(); + DIR* dir = opendir(source.value().c_str()); + if (!dir) + return false; + +#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_BSD) && \ + !defined(OS_SOLARIS) && !defined(OS_ANDROID) + #error Port warning: depending on the definition of struct dirent, \ + additional space for pathname may be needed +#endif + + struct dirent dent_buf; + struct dirent* dent; + while (readdir_r(dir, &dent_buf, &dent) == 0 && dent) { + DirectoryEntryInfo info; + info.filename = FilePath(dent->d_name); + + FilePath full_name = source.Append(dent->d_name); + int ret; + if (show_links) + ret = lstat(full_name.value().c_str(), &info.stat); + else + ret = stat(full_name.value().c_str(), &info.stat); + if (ret < 0) { + // Print the stat() error message unless it was ENOENT and we're + // following symlinks. + if (!(errno == ENOENT && !show_links)) { + DPLOG(ERROR) << "Couldn't stat " + << source.Append(dent->d_name).value(); + } + memset(&info.stat, 0, sizeof(info.stat)); + } + entries->push_back(info); + } + + closedir(dir); + return true; +} + bool NormalizeFilePath(const FilePath& path, FilePath* normalized_path) { FilePath real_path_result; if (!RealPath(path, &real_path_result)) diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 593ae81..5cfc677 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -18,7 +18,6 @@ #include "base/base_paths.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" @@ -35,7 +34,6 @@ // This macro helps avoid wrapped lines in the test structs. #define FPL(x) FILE_PATH_LITERAL(x) -using base::FileEnumerator; using base::FilePath; namespace { @@ -136,7 +134,7 @@ void ChangePosixFilePermissions(const FilePath& path, const wchar_t bogus_content[] = L"I'm cannon fodder."; const int FILES_AND_DIRECTORIES = - FileEnumerator::FILES | FileEnumerator::DIRECTORIES; + file_util::FileEnumerator::FILES | file_util::FileEnumerator::DIRECTORIES; // file_util winds up using autoreleased objects on the Mac, so this needs // to be a PlatformTest @@ -154,7 +152,7 @@ class FileUtilTest : public PlatformTest { // interface to query whether a given file is present. class FindResultCollector { public: - explicit FindResultCollector(FileEnumerator& enumerator) { + explicit FindResultCollector(file_util::FileEnumerator& enumerator) { FilePath cur_file; while (!(cur_file = enumerator.Next()).value().empty()) { FilePath::StringType path = cur_file.value(); @@ -919,7 +917,8 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { EXPECT_FALSE(mode & file_util::FILE_PERMISSION_USER_MASK); // Make sure the file in the directory can't be enumerated. - FileEnumerator f1(subdir_path, true, FileEnumerator::FILES); + file_util::FileEnumerator f1(subdir_path, true, + file_util::FileEnumerator::FILES); EXPECT_TRUE(file_util::PathExists(subdir_path)); FindResultCollector c1(f1); EXPECT_EQ(c1.size(), 0); @@ -934,7 +933,8 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { mode & file_util::FILE_PERMISSION_USER_MASK); // Make sure the file in the directory can be enumerated. - FileEnumerator f2(subdir_path, true, FileEnumerator::FILES); + file_util::FileEnumerator f2(subdir_path, true, + file_util::FileEnumerator::FILES); FindResultCollector c2(f2); EXPECT_TRUE(c2.HasFile(file_name)); EXPECT_EQ(c2.size(), 1); @@ -1824,13 +1824,13 @@ TEST_F(FileUtilTest, DetectDirectoryTest) { TEST_F(FileUtilTest, FileEnumeratorTest) { // Test an empty directory. - FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES); + file_util::FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES); EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL("")); EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL("")); // Test an empty directory, non-recursively, including "..". - FileEnumerator f0_dotdot(temp_dir_.path(), false, - FILES_AND_DIRECTORIES | FileEnumerator::INCLUDE_DOT_DOT); + file_util::FileEnumerator f0_dotdot(temp_dir_.path(), false, + FILES_AND_DIRECTORIES | file_util::FileEnumerator::INCLUDE_DOT_DOT); EXPECT_EQ(temp_dir_.path().Append(FILE_PATH_LITERAL("..")).value(), f0_dotdot.Next().value()); EXPECT_EQ(FILE_PATH_LITERAL(""), @@ -1857,7 +1857,8 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { FilePath file2_abs = temp_dir_.path().Append(FILE_PATH_LITERAL("file2.txt")); // Only enumerate files. - FileEnumerator f1(temp_dir_.path(), true, FileEnumerator::FILES); + file_util::FileEnumerator f1(temp_dir_.path(), true, + file_util::FileEnumerator::FILES); FindResultCollector c1(f1); EXPECT_TRUE(c1.HasFile(file1)); EXPECT_TRUE(c1.HasFile(file2_abs)); @@ -1866,7 +1867,8 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { EXPECT_EQ(c1.size(), 4); // Only enumerate directories. - FileEnumerator f2(temp_dir_.path(), true, FileEnumerator::DIRECTORIES); + file_util::FileEnumerator f2(temp_dir_.path(), true, + file_util::FileEnumerator::DIRECTORIES); FindResultCollector c2(f2); EXPECT_TRUE(c2.HasFile(dir1)); EXPECT_TRUE(c2.HasFile(dir2)); @@ -1874,17 +1876,17 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { EXPECT_EQ(c2.size(), 3); // Only enumerate directories non-recursively. - FileEnumerator f2_non_recursive( - temp_dir_.path(), false, FileEnumerator::DIRECTORIES); + file_util::FileEnumerator f2_non_recursive( + temp_dir_.path(), false, file_util::FileEnumerator::DIRECTORIES); FindResultCollector c2_non_recursive(f2_non_recursive); EXPECT_TRUE(c2_non_recursive.HasFile(dir1)); EXPECT_TRUE(c2_non_recursive.HasFile(dir2)); EXPECT_EQ(c2_non_recursive.size(), 2); // Only enumerate directories, non-recursively, including "..". - FileEnumerator f2_dotdot(temp_dir_.path(), false, - FileEnumerator::DIRECTORIES | - FileEnumerator::INCLUDE_DOT_DOT); + file_util::FileEnumerator f2_dotdot(temp_dir_.path(), false, + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::INCLUDE_DOT_DOT); FindResultCollector c2_dotdot(f2_dotdot); EXPECT_TRUE(c2_dotdot.HasFile(dir1)); EXPECT_TRUE(c2_dotdot.HasFile(dir2)); @@ -1893,7 +1895,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { EXPECT_EQ(c2_dotdot.size(), 3); // Enumerate files and directories. - FileEnumerator f3(temp_dir_.path(), true, FILES_AND_DIRECTORIES); + file_util::FileEnumerator f3(temp_dir_.path(), true, FILES_AND_DIRECTORIES); FindResultCollector c3(f3); EXPECT_TRUE(c3.HasFile(dir1)); EXPECT_TRUE(c3.HasFile(dir2)); @@ -1905,7 +1907,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { EXPECT_EQ(c3.size(), 7); // Non-recursive operation. - FileEnumerator f4(temp_dir_.path(), false, FILES_AND_DIRECTORIES); + file_util::FileEnumerator f4(temp_dir_.path(), false, FILES_AND_DIRECTORIES); FindResultCollector c4(f4); EXPECT_TRUE(c4.HasFile(dir2)); EXPECT_TRUE(c4.HasFile(dir2)); @@ -1914,7 +1916,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { EXPECT_EQ(c4.size(), 4); // Enumerate with a pattern. - FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES, + file_util::FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES, FILE_PATH_LITERAL("dir*")); FindResultCollector c5(f5); EXPECT_TRUE(c5.HasFile(dir1)); @@ -1926,7 +1928,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { // Make sure the destructor closes the find handle while in the middle of a // query to allow TearDown to delete the directory. - FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES); + file_util::FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES); EXPECT_FALSE(f6.Next().value().empty()); // Should have found something // (we don't care what). } diff --git a/base/file_util_win.cc b/base/file_util_win.cc index b166322..964302a 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -595,6 +595,139 @@ bool SetCurrentDirectory(const FilePath& directory) { return ret != 0; } +/////////////////////////////////////////////// +// FileEnumerator + +FileEnumerator::FileEnumerator(const FilePath& root_path, + bool recursive, + int file_type) + : recursive_(recursive), + file_type_(file_type), + has_find_data_(false), + find_handle_(INVALID_HANDLE_VALUE) { + // INCLUDE_DOT_DOT must not be specified if recursive. + DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); + memset(&find_data_, 0, sizeof(find_data_)); + pending_paths_.push(root_path); +} + +FileEnumerator::FileEnumerator(const FilePath& root_path, + bool recursive, + int file_type, + const FilePath::StringType& pattern) + : recursive_(recursive), + file_type_(file_type), + has_find_data_(false), + pattern_(pattern), + find_handle_(INVALID_HANDLE_VALUE) { + // INCLUDE_DOT_DOT must not be specified if recursive. + DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); + memset(&find_data_, 0, sizeof(find_data_)); + pending_paths_.push(root_path); +} + +FileEnumerator::~FileEnumerator() { + if (find_handle_ != INVALID_HANDLE_VALUE) + FindClose(find_handle_); +} + +void FileEnumerator::GetFindInfo(FindInfo* info) { + DCHECK(info); + + if (!has_find_data_) + return; + + memcpy(info, &find_data_, sizeof(*info)); +} + +// static +bool FileEnumerator::IsDirectory(const FindInfo& info) { + return (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; +} + +// static +FilePath FileEnumerator::GetFilename(const FindInfo& find_info) { + return FilePath(find_info.cFileName); +} + +// static +int64 FileEnumerator::GetFilesize(const FindInfo& find_info) { + ULARGE_INTEGER size; + size.HighPart = find_info.nFileSizeHigh; + size.LowPart = find_info.nFileSizeLow; + DCHECK_LE(size.QuadPart, std::numeric_limits<int64>::max()); + return static_cast<int64>(size.QuadPart); +} + +// static +base::Time FileEnumerator::GetLastModifiedTime(const FindInfo& find_info) { + return base::Time::FromFileTime(find_info.ftLastWriteTime); +} + +FilePath FileEnumerator::Next() { + base::ThreadRestrictions::AssertIOAllowed(); + + while (has_find_data_ || !pending_paths_.empty()) { + if (!has_find_data_) { + // The last find FindFirstFile operation is done, prepare a new one. + root_path_ = pending_paths_.top(); + pending_paths_.pop(); + + // Start a new find operation. + FilePath src = root_path_; + + if (pattern_.empty()) + src = src.Append(L"*"); // No pattern = match everything. + else + src = src.Append(pattern_); + + find_handle_ = FindFirstFile(src.value().c_str(), &find_data_); + has_find_data_ = true; + } else { + // Search for the next file/directory. + if (!FindNextFile(find_handle_, &find_data_)) { + FindClose(find_handle_); + find_handle_ = INVALID_HANDLE_VALUE; + } + } + + if (INVALID_HANDLE_VALUE == find_handle_) { + has_find_data_ = false; + + // This is reached when we have finished a directory and are advancing to + // the next one in the queue. We applied the pattern (if any) to the files + // in the root search directory, but for those directories which were + // matched, we want to enumerate all files inside them. This will happen + // when the handle is empty. + pattern_ = FilePath::StringType(); + + continue; + } + + FilePath cur_file(find_data_.cFileName); + if (ShouldSkip(cur_file)) + continue; + + // Construct the absolute filename. + cur_file = root_path_.Append(find_data_.cFileName); + + if (find_data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if (recursive_) { + // If |cur_file| is a directory, and we are doing recursive searching, + // add it to pending_paths_ so we scan it after we finish scanning this + // directory. + pending_paths_.push(cur_file); + } + if (file_type_ & FileEnumerator::DIRECTORIES) + return cur_file; + } else if (file_type_ & FileEnumerator::FILES) { + return cur_file; + } + } + + return FilePath(); +} + bool NormalizeFilePath(const FilePath& path, FilePath* real_path) { base::ThreadRestrictions::AssertIOAllowed(); FilePath mapped_file; diff --git a/base/files/file_enumerator.cc b/base/files/file_enumerator.cc deleted file mode 100644 index e49f465..0000000 --- a/base/files/file_enumerator.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/files/file_enumerator.h" - -#include "base/file_util.h" - -namespace base { - -FileEnumerator::FileInfo::~FileInfo() { -} - -bool FileEnumerator::ShouldSkip(const FilePath& path) { - FilePath::StringType basename = path.BaseName().value(); - return basename == FILE_PATH_LITERAL(".") || - (basename == FILE_PATH_LITERAL("..") && - !(INCLUDE_DOT_DOT & file_type_)); -} - -} // namespace base diff --git a/base/files/file_enumerator.h b/base/files/file_enumerator.h deleted file mode 100644 index 3834281..0000000 --- a/base/files/file_enumerator.h +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_FILES_FILE_ENUMERATOR_H_ -#define BASE_FILES_FILE_ENUMERATOR_H_ - -#include <stack> -#include <vector> - -#include "base/base_export.h" -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "base/time.h" -#include "build/build_config.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_POSIX) -#include <sys/stat.h> -#include <unistd.h> -#endif - -namespace base { - -// A class for enumerating the files in a provided path. The order of the -// results is not guaranteed. -// -// This is blocking. Do not use on critical threads. -// -// Example: -// -// base::FileEnumerator enum(my_dir, false, base::FileEnumerator::FILES, -// FILE_PATH_LITERAL("*.txt")); -// for (base::FilePath name = enum.Next(); !name.empty(); name = enum.Next()) -// ... -class BASE_EXPORT FileEnumerator { - public: - // Note: copy & assign supported. - class FileInfo { - public: - FileInfo(); - ~FileInfo(); - - bool IsDirectory() const; - - // The name of the file. This will not include any path information. This - // is in constrast to the value returned by FileEnumerator.Next() which - // includes the |root_path| passed into the FileEnumerator constructor. - FilePath GetName() const; - - int64 GetSize() const; - Time GetLastModifiedTime() const; - -#if defined(OS_WIN) - const WIN32_FIND_DATA& find_data() const { return find_data_; } -#elif defined(OS_POSIX) - const struct stat& stat() const { return stat_; } -#endif - - private: - friend class FileEnumerator; - -#if defined(OS_WIN) - WIN32_FIND_DATA find_data_; -#elif defined(OS_POSIX) - struct stat stat_; - FilePath filename_; -#endif - }; - - enum FileType { - FILES = 1 << 0, - DIRECTORIES = 1 << 1, - INCLUDE_DOT_DOT = 1 << 2, -#if defined(OS_POSIX) - SHOW_SYM_LINKS = 1 << 4, -#endif - }; - - // |root_path| is the starting directory to search for. It may or may not end - // in a slash. - // - // If |recursive| is true, this will enumerate all matches in any - // subdirectories matched as well. It does a breadth-first search, so all - // files in one directory will be returned before any files in a - // subdirectory. - // - // |file_type|, a bit mask of FileType, specifies whether the enumerator - // should match files, directories, or both. - // - // |pattern| is an optional pattern for which files to match. This - // works like shell globbing. For example, "*.txt" or "Foo???.doc". - // However, be careful in specifying patterns that aren't cross platform - // since the underlying code uses OS-specific matching routines. In general, - // Windows matching is less featureful than others, so test there first. - // If unspecified, this will match all files. - // NOTE: the pattern only matches the contents of root_path, not files in - // recursive subdirectories. - // TODO(erikkay): Fix the pattern matching to work at all levels. - FileEnumerator(const FilePath& root_path, - bool recursive, - int file_type); - FileEnumerator(const FilePath& root_path, - bool recursive, - int file_type, - const FilePath::StringType& pattern); - ~FileEnumerator(); - - // Returns the next file or an empty string if there are no more results. - // - // The returned path will incorporate the |root_path| passed in the - // constructor: "<root_path>/file_name.txt". If the |root_path| is absolute, - // then so will be the result of Next(). - FilePath Next(); - - // Write the file info into |info|. - FileInfo GetInfo() const; - - private: - // Returns true if the given path should be skipped in enumeration. - bool ShouldSkip(const FilePath& path); - -#if defined(OS_WIN) - // True when find_data_ is valid. - bool has_find_data_; - WIN32_FIND_DATA find_data_; - HANDLE find_handle_; -#elif defined(OS_POSIX) - - // Read the filenames in source into the vector of DirectoryEntryInfo's - static bool ReadDirectory(std::vector<FileInfo>* entries, - const FilePath& source, bool show_links); - - // The files in the current directory - std::vector<FileInfo> directory_entries_; - - // The next entry to use from the directory_entries_ vector - size_t current_directory_entry_; -#endif - - FilePath root_path_; - bool recursive_; - int file_type_; - FilePath::StringType pattern_; // Empty when we want to find everything. - - // A stack that keeps track of which subdirectories we still need to - // enumerate in the breadth-first search. - std::stack<FilePath> pending_paths_; - - DISALLOW_COPY_AND_ASSIGN(FileEnumerator); -}; - -} // namespace base - -#endif // BASE_FILES_FILE_ENUMERATOR_H_ diff --git a/base/files/file_enumerator_posix.cc b/base/files/file_enumerator_posix.cc deleted file mode 100644 index 7533a24..0000000 --- a/base/files/file_enumerator_posix.cc +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/files/file_enumerator.h" - -#include <dirent.h> -#include <errno.h> -#include <fnmatch.h> - -#include "base/logging.h" -#include "base/threading/thread_restrictions.h" - -namespace base { - -// FileEnumerator::FileInfo ---------------------------------------------------- - -FileEnumerator::FileInfo::FileInfo() { - memset(&stat_, 0, sizeof(stat_)); -} - -bool FileEnumerator::FileInfo::IsDirectory() const { - return S_ISDIR(stat_.st_mode); -} - -FilePath FileEnumerator::FileInfo::GetName() const { - return filename_; -} - -int64 FileEnumerator::FileInfo::GetSize() const { - return stat_.st_size; -} - -base::Time FileEnumerator::FileInfo::GetLastModifiedTime() const { - return base::Time::FromTimeT(stat_.st_mtime); -} - -// FileEnumerator -------------------------------------------------------------- - -FileEnumerator::FileEnumerator(const FilePath& root_path, - bool recursive, - int file_type) - : current_directory_entry_(0), - root_path_(root_path), - recursive_(recursive), - file_type_(file_type) { - // INCLUDE_DOT_DOT must not be specified if recursive. - DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); - pending_paths_.push(root_path); -} - -FileEnumerator::FileEnumerator(const FilePath& root_path, - bool recursive, - int file_type, - const FilePath::StringType& pattern) - : current_directory_entry_(0), - root_path_(root_path), - recursive_(recursive), - file_type_(file_type), - pattern_(root_path.Append(pattern).value()) { - // INCLUDE_DOT_DOT must not be specified if recursive. - DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); - // The Windows version of this code appends the pattern to the root_path, - // potentially only matching against items in the top-most directory. - // Do the same here. - if (pattern.empty()) - pattern_ = FilePath::StringType(); - pending_paths_.push(root_path); -} - -FileEnumerator::~FileEnumerator() { -} - -FilePath FileEnumerator::Next() { - ++current_directory_entry_; - - // While we've exhausted the entries in the current directory, do the next - while (current_directory_entry_ >= directory_entries_.size()) { - if (pending_paths_.empty()) - return FilePath(); - - root_path_ = pending_paths_.top(); - root_path_ = root_path_.StripTrailingSeparators(); - pending_paths_.pop(); - - std::vector<FileInfo> entries; - if (!ReadDirectory(&entries, root_path_, file_type_ & SHOW_SYM_LINKS)) - continue; - - directory_entries_.clear(); - current_directory_entry_ = 0; - for (std::vector<FileInfo>::const_iterator i = entries.begin(); - i != entries.end(); ++i) { - FilePath full_path = root_path_.Append(i->filename_); - if (ShouldSkip(full_path)) - continue; - - if (pattern_.size() && - fnmatch(pattern_.c_str(), full_path.value().c_str(), FNM_NOESCAPE)) - continue; - - if (recursive_ && S_ISDIR(i->stat_.st_mode)) - pending_paths_.push(full_path); - - if ((S_ISDIR(i->stat_.st_mode) && (file_type_ & DIRECTORIES)) || - (!S_ISDIR(i->stat_.st_mode) && (file_type_ & FILES))) - directory_entries_.push_back(*i); - } - } - - return root_path_.Append( - directory_entries_[current_directory_entry_].filename_); -} - -FileEnumerator::FileInfo FileEnumerator::GetInfo() const { - return directory_entries_[current_directory_entry_]; -} - -bool FileEnumerator::ReadDirectory(std::vector<FileInfo>* entries, - const FilePath& source, bool show_links) { - base::ThreadRestrictions::AssertIOAllowed(); - DIR* dir = opendir(source.value().c_str()); - if (!dir) - return false; - -#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_BSD) && \ - !defined(OS_SOLARIS) && !defined(OS_ANDROID) - #error Port warning: depending on the definition of struct dirent, \ - additional space for pathname may be needed -#endif - - struct dirent dent_buf; - struct dirent* dent; - while (readdir_r(dir, &dent_buf, &dent) == 0 && dent) { - FileInfo info; - info.filename_ = FilePath(dent->d_name); - - FilePath full_name = source.Append(dent->d_name); - int ret; - if (show_links) - ret = lstat(full_name.value().c_str(), &info.stat_); - else - ret = stat(full_name.value().c_str(), &info.stat_); - if (ret < 0) { - // Print the stat() error message unless it was ENOENT and we're - // following symlinks. - if (!(errno == ENOENT && !show_links)) { - DPLOG(ERROR) << "Couldn't stat " - << source.Append(dent->d_name).value(); - } - memset(&info.stat_, 0, sizeof(info.stat_)); - } - entries->push_back(info); - } - - closedir(dir); - return true; -} - -} // namespace base diff --git a/base/files/file_enumerator_win.cc b/base/files/file_enumerator_win.cc deleted file mode 100644 index 64c9845..0000000 --- a/base/files/file_enumerator_win.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/files/file_enumerator.h" - -#include <string.h> - -#include "base/logging.h" -#include "base/threading/thread_restrictions.h" - -namespace base { - -// FileEnumerator::FileInfo ---------------------------------------------------- - -FileEnumerator::FileInfo::FileInfo() { - memset(&find_data_, 0, sizeof(find_data_)); -} - -bool FileEnumerator::FileInfo::IsDirectory() const { - return (find_data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; -} - -FilePath FileEnumerator::FileInfo::GetName() const { - return FilePath(find_data_.cFileName); -} - -int64 FileEnumerator::FileInfo::GetSize() const { - ULARGE_INTEGER size; - size.HighPart = find_data_.nFileSizeHigh; - size.LowPart = find_data_.nFileSizeLow; - DCHECK_LE(size.QuadPart, std::numeric_limits<int64>::max()); - return static_cast<int64>(size.QuadPart); -} - -base::Time FileEnumerator::FileInfo::GetLastModifiedTime() const { - return base::Time::FromFileTime(find_data_.ftLastWriteTime); -} - -// FileEnumerator -------------------------------------------------------------- - -FileEnumerator::FileEnumerator(const FilePath& root_path, - bool recursive, - int file_type) - : recursive_(recursive), - file_type_(file_type), - has_find_data_(false), - find_handle_(INVALID_HANDLE_VALUE) { - // INCLUDE_DOT_DOT must not be specified if recursive. - DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); - memset(&find_data_, 0, sizeof(find_data_)); - pending_paths_.push(root_path); -} - -FileEnumerator::FileEnumerator(const FilePath& root_path, - bool recursive, - int file_type, - const FilePath::StringType& pattern) - : recursive_(recursive), - file_type_(file_type), - has_find_data_(false), - pattern_(pattern), - find_handle_(INVALID_HANDLE_VALUE) { - // INCLUDE_DOT_DOT must not be specified if recursive. - DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); - memset(&find_data_, 0, sizeof(find_data_)); - pending_paths_.push(root_path); -} - -FileEnumerator::~FileEnumerator() { - if (find_handle_ != INVALID_HANDLE_VALUE) - FindClose(find_handle_); -} - -FileEnumerator::FileInfo FileEnumerator::GetInfo() const { - if (!has_find_data_) { - NOTREACHED(); - return FileInfo(); - } - FileInfo ret; - memcpy(&ret.find_data_, &find_data_, sizeof(find_data_)); - return ret; -} - -FilePath FileEnumerator::Next() { - base::ThreadRestrictions::AssertIOAllowed(); - - while (has_find_data_ || !pending_paths_.empty()) { - if (!has_find_data_) { - // The last find FindFirstFile operation is done, prepare a new one. - root_path_ = pending_paths_.top(); - pending_paths_.pop(); - - // Start a new find operation. - FilePath src = root_path_; - - if (pattern_.empty()) - src = src.Append(L"*"); // No pattern = match everything. - else - src = src.Append(pattern_); - - find_handle_ = FindFirstFile(src.value().c_str(), &find_data_); - has_find_data_ = true; - } else { - // Search for the next file/directory. - if (!FindNextFile(find_handle_, &find_data_)) { - FindClose(find_handle_); - find_handle_ = INVALID_HANDLE_VALUE; - } - } - - if (INVALID_HANDLE_VALUE == find_handle_) { - has_find_data_ = false; - - // This is reached when we have finished a directory and are advancing to - // the next one in the queue. We applied the pattern (if any) to the files - // in the root search directory, but for those directories which were - // matched, we want to enumerate all files inside them. This will happen - // when the handle is empty. - pattern_ = FilePath::StringType(); - - continue; - } - - FilePath cur_file(find_data_.cFileName); - if (ShouldSkip(cur_file)) - continue; - - // Construct the absolute filename. - cur_file = root_path_.Append(find_data_.cFileName); - - if (find_data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - if (recursive_) { - // If |cur_file| is a directory, and we are doing recursive searching, - // add it to pending_paths_ so we scan it after we finish scanning this - // directory. - pending_paths_.push(cur_file); - } - if (file_type_ & FileEnumerator::DIRECTORIES) - return cur_file; - } else if (file_type_ & FileEnumerator::FILES) { - return cur_file; - } - } - - return FilePath(); -} - -} // namespace base diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index d80a954..7c16cb18 100644 --- a/base/test/test_file_util_posix.cc +++ b/base/test/test_file_util_posix.cc @@ -12,12 +12,13 @@ #include <string> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +using base::MakeAbsoluteFilePath; + namespace file_util { namespace { diff --git a/chrome/browser/browsing_data/browsing_data_local_storage_helper_browsertest.cc b/chrome/browser/browsing_data/browsing_data_local_storage_helper_browsertest.cc index 5b45199..b123b89 100644 --- a/chrome/browser/browsing_data/browsing_data_local_storage_helper_browsertest.cc +++ b/chrome/browser/browsing_data/browsing_data_local_storage_helper_browsertest.cc @@ -9,7 +9,6 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/test/thread_test_helper.h" @@ -130,10 +129,10 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { BrowserThread::GetBlockingPool()->FlushForTesting(); // Ensure the file has been deleted. - base::FileEnumerator file_enumerator( + file_util::FileEnumerator file_enumerator( GetLocalStoragePathForTestingProfile(), false, - base::FileEnumerator::FILES); + file_util::FileEnumerator::FILES); int num_files = 0; for (base::FilePath file_path = file_enumerator.Next(); !file_path.empty(); diff --git a/chrome/browser/chromeos/camera_detector.cc b/chrome/browser/chromeos/camera_detector.cc index 3d5d039..e7fddb9 100644 --- a/chrome/browser/chromeos/camera_detector.cc +++ b/chrome/browser/chromeos/camera_detector.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/location.h" #include "base/string_util.h" #include "base/strings/string_split.h" @@ -67,9 +66,10 @@ void CameraDetector::OnPresenceCheckDone(const base::Closure& callback, bool CameraDetector::CheckPresence() { // We do a quick check using udev database because opening each /dev/videoX // device may trigger costly device initialization. - base::FileEnumerator file_enum( + using file_util::FileEnumerator; + FileEnumerator file_enum( base::FilePath(kV4LSubsystemDir), false /* not recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS); + FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS); for (base::FilePath path = file_enum.Next(); !path.empty(); path = file_enum.Next()) { std::string v4l_capabilities; diff --git a/chrome/browser/chromeos/contacts/contact_database_unittest.cc b/chrome/browser/chromeos/contacts/contact_database_unittest.cc index 959d9eb..c32cad0 100644 --- a/chrome/browser/chromeos/contacts/contact_database_unittest.cc +++ b/chrome/browser/chromeos/contacts/contact_database_unittest.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" @@ -315,8 +314,8 @@ TEST_F(ContactDatabaseTest, FullAndIncrementalUpdates) { TEST_F(ContactDatabaseTest, DeleteWhenCorrupt) { DestroyDatabase(); // Overwrite all of the files in the database with a space character. - base::FileEnumerator enumerator( - database_path(), false, base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator( + database_path(), false, file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.empty(); path = enumerator.Next()) { file_util::WriteFile(path, " ", 1); diff --git a/chrome/browser/chromeos/drive/file_cache.cc b/chrome/browser/chromeos/drive/file_cache.cc index dbbc40e..6e312eb 100644 --- a/chrome/browser/chromeos/drive/file_cache.cc +++ b/chrome/browser/chromeos/drive/file_cache.cc @@ -7,7 +7,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -63,8 +62,10 @@ bool InitCachePaths(const std::vector<base::FilePath>& cache_paths) { // Do not remove recursively as we don't want to touch <gcache>/tmp/downloads, // which is used for user initiated downloads like "Save As" void RemoveAllFiles(const base::FilePath& directory) { - base::FileEnumerator enumerator(directory, false /* recursive */, - base::FileEnumerator::FILES); + using file_util::FileEnumerator; + + FileEnumerator enumerator(directory, false /* recursive */, + FileEnumerator::FILES); for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); file_path = enumerator.Next()) { DVLOG(1) << "Removing " << file_path.value(); @@ -130,9 +131,11 @@ void DeleteFilesSelectively(const base::FilePath& path_to_delete_pattern, // base name of |path_to_delete_pattern|. // If a file is not |path_to_keep|, delete it. bool success = true; - base::FileEnumerator enumerator(path_to_delete_pattern.DirName(), + file_util::FileEnumerator enumerator( + path_to_delete_pattern.DirName(), false, // not recursive - base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::SHOW_SYM_LINKS, path_to_delete_pattern.BaseName().value()); for (base::FilePath current = enumerator.Next(); !current.empty(); current = enumerator.Next()) { diff --git a/chrome/browser/chromeos/drive/file_cache_metadata.cc b/chrome/browser/chromeos/drive/file_cache_metadata.cc index 244df4b..ae40aed 100644 --- a/chrome/browser/chromeos/drive/file_cache_metadata.cc +++ b/chrome/browser/chromeos/drive/file_cache_metadata.cc @@ -6,7 +6,6 @@ #include "base/callback.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/metrics/histogram.h" #include "base/sequenced_task_runner.h" #include "chrome/browser/chromeos/drive/drive.pb.h" @@ -71,10 +70,11 @@ void ScanCacheDirectory( DCHECK(cache_map); DCHECK(processed_file_map); - base::FileEnumerator enumerator( + file_util::FileEnumerator enumerator( cache_paths[sub_dir_type], false, // not recursive - base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::SHOW_SYM_LINKS, util::kWildCard); for (base::FilePath current = enumerator.Next(); !current.empty(); current = enumerator.Next()) { diff --git a/chrome/browser/chromeos/drive/file_cache_unittest.cc b/chrome/browser/chromeos/drive/file_cache_unittest.cc index 0b943e0..23de08e 100644 --- a/chrome/browser/chromeos/drive/file_cache_unittest.cc +++ b/chrome/browser/chromeos/drive/file_cache_unittest.cc @@ -8,7 +8,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/message_loop.h" #include "base/threading/sequenced_worker_pool.h" @@ -286,9 +285,10 @@ class FileCacheTest : public testing::Test { FileCache::CACHED_FILE_FROM_SERVER), base::FilePath())); if (!cache_entry_found) { for (size_t i = 0; i < paths_to_verify.size(); ++i) { - base::FileEnumerator enumerator( + file_util::FileEnumerator enumerator( paths_to_verify[i].path_to_scan.DirName(), false /* not recursive*/, - base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::SHOW_SYM_LINKS, paths_to_verify[i].path_to_scan.BaseName().value()); EXPECT_TRUE(enumerator.Next().empty()); } @@ -315,9 +315,10 @@ class FileCacheTest : public testing::Test { for (size_t i = 0; i < paths_to_verify.size(); ++i) { const struct PathToVerify& verify = paths_to_verify[i]; - base::FileEnumerator enumerator( + file_util::FileEnumerator enumerator( verify.path_to_scan.DirName(), false /* not recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::SHOW_SYM_LINKS, verify.path_to_scan.BaseName().value()); size_t num_files_found = 0; for (base::FilePath current = enumerator.Next(); !current.empty(); @@ -620,9 +621,9 @@ class FileCacheTest : public testing::Test { FileCache::CACHE_TYPE_PERSISTENT : FileCache::CACHE_TYPE_TMP), FileCache::CACHED_FILE_FROM_SERVER); - base::FileEnumerator enumerator(path.DirName(), false, - base::FileEnumerator::FILES, - path.BaseName().value()); + file_util::FileEnumerator enumerator(path.DirName(), false, + file_util::FileEnumerator::FILES, + path.BaseName().value()); size_t num_files_found = 0; for (base::FilePath current = enumerator.Next(); !current.empty(); current = enumerator.Next()) { diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc index d2a855e..ac32448 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc @@ -10,7 +10,6 @@ #include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_util.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" @@ -886,8 +885,8 @@ void WallpaperPrivateGetOfflineWallpaperListFunction::GetList( base::FilePath wallpaper_dir; CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir)); if (file_util::DirectoryExists(wallpaper_dir)) { - base::FileEnumerator files(wallpaper_dir, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator files(wallpaper_dir, false, + file_util::FileEnumerator::FILES); for (base::FilePath current = files.Next(); !current.empty(); current = files.Next()) { std::string file_name = current.BaseName().RemoveExtension().value(); @@ -900,8 +899,8 @@ void WallpaperPrivateGetOfflineWallpaperListFunction::GetList( base::FilePath custom_thumbnails_dir = chromeos::WallpaperManager::Get()-> GetCustomWallpaperPath(chromeos::kThumbnailWallpaperSubDir, email, ""); if (file_util::DirectoryExists(custom_thumbnails_dir)) { - base::FileEnumerator files(custom_thumbnails_dir, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator files(custom_thumbnails_dir, false, + file_util::FileEnumerator::FILES); std::set<std::string> file_name_set; for (base::FilePath current = files.Next(); !current.empty(); current = files.Next()) { diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc index 95adc86..0613513 100644 --- a/chrome/browser/chromeos/login/wallpaper_manager.cc +++ b/chrome/browser/chromeos/login/wallpaper_manager.cc @@ -9,7 +9,6 @@ #include "ash/shell.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/metrics/histogram.h" @@ -685,7 +684,8 @@ void WallpaperManager::ClearObsoleteWallpaperPrefs() { void WallpaperManager::DeleteAllExcept(const base::FilePath& path) { base::FilePath dir = path.DirName(); if (file_util::DirectoryExists(dir)) { - base::FileEnumerator files(dir, false, base::FileEnumerator::FILES); + file_util::FileEnumerator files(dir, false, + file_util::FileEnumerator::FILES); for (base::FilePath current = files.Next(); !current.empty(); current = files.Next()) { if (current != path) diff --git a/chrome/browser/chromeos/policy/app_pack_updater.cc b/chrome/browser/chromeos/policy/app_pack_updater.cc index 156402a5..61fe56f 100644 --- a/chrome/browser/chromeos/policy/app_pack_updater.cc +++ b/chrome/browser/chromeos/policy/app_pack_updater.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/location.h" #include "base/stl_util.h" #include "base/string_util.h" @@ -30,6 +29,7 @@ #include "content/public/browser/notification_source.h" using content::BrowserThread; +using file_util::FileEnumerator; namespace policy { @@ -250,16 +250,18 @@ void AppPackUpdater::BlockingCheckCacheInternal( // Enumerate all the files in the cache |dir|, including directories // and symlinks. Each unrecognized file will be erased. - int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES | - base::FileEnumerator::SHOW_SYM_LINKS; - base::FileEnumerator enumerator(dir, false /* recursive */, types); + int types = FileEnumerator::FILES | FileEnumerator::DIRECTORIES | + FileEnumerator::SHOW_SYM_LINKS; + FileEnumerator enumerator(dir, false /* recursive */, types); for (base::FilePath path = enumerator.Next(); !path.empty(); path = enumerator.Next()) { - base::FileEnumerator::FileInfo info = enumerator.GetInfo(); + FileEnumerator::FindInfo info; + enumerator.GetFindInfo(&info); std::string basename = path.BaseName().value(); - if (info.IsDirectory() || file_util::IsLink(info.GetName())) { + if (FileEnumerator::IsDirectory(info) || + file_util::IsLink(FileEnumerator::GetFilename(info))) { LOG(ERROR) << "Erasing bad file in AppPack directory: " << basename; file_util::Delete(path, true /* recursive */); continue; diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc index 0203a54..2663824 100644 --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc @@ -13,7 +13,6 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" @@ -96,8 +95,8 @@ bool GetPepperFlashDirectory(base::FilePath* latest_dir, std::vector<base::FilePath>* older_dirs) { base::FilePath base_dir = GetPepperFlashBaseDirectory(); bool found = false; - base::FileEnumerator - file_enumerator(base_dir, false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator + file_enumerator(base_dir, false, file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { Version version(path.BaseName().MaybeAsASCII()); diff --git a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc index 07e5abc..f66b8a9 100644 --- a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc +++ b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc @@ -9,7 +9,6 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/json/json_file_value_serializer.h" #include "base/logging.h" @@ -127,8 +126,8 @@ bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci, // Enumerate all versions starting from the base directory. base::FilePath base_dir = pci->GetPnaclBaseDirectory(); bool found = false; - base::FileEnumerator - file_enumerator(base_dir, false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator + file_enumerator(base_dir, false, file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { Version version(path.BaseName().MaybeAsASCII()); diff --git a/chrome/browser/component_updater/swiftshader_component_installer.cc b/chrome/browser/component_updater/swiftshader_component_installer.cc index f71fd5a..8e365da 100644 --- a/chrome/browser/component_updater/swiftshader_component_installer.cc +++ b/chrome/browser/component_updater/swiftshader_component_installer.cc @@ -9,7 +9,6 @@ #include "base/compiler_specific.h" #include "base/cpu.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" @@ -64,8 +63,8 @@ bool GetLatestSwiftShaderDirectory(base::FilePath* result, std::vector<base::FilePath>* older_dirs) { base::FilePath base_dir = GetSwiftShaderBaseDirectory(); bool found = false; - base::FileEnumerator - file_enumerator(base_dir, false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator + file_enumerator(base_dir, false, file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { Version version(path.BaseName().MaybeAsASCII()); diff --git a/chrome/browser/component_updater/widevine_cdm_component_installer.cc b/chrome/browser/component_updater/widevine_cdm_component_installer.cc index 123c5fc..f43c28a 100644 --- a/chrome/browser/component_updater/widevine_cdm_component_installer.cc +++ b/chrome/browser/component_updater/widevine_cdm_component_installer.cc @@ -13,7 +13,6 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" @@ -94,8 +93,8 @@ bool GetWidevineCdmDirectory(base::FilePath* latest_dir, std::vector<base::FilePath>* older_dirs) { base::FilePath base_dir = GetWidevineCdmBaseDirectory(); bool found = false; - base::FileEnumerator file_enumerator( - base_dir, false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator file_enumerator( + base_dir, false, file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { base::Version version(path.BaseName().MaybeAsASCII()); diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc index 85a7822..5251024 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc @@ -6,7 +6,6 @@ #include "base/base64.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/i18n/file_util_icu.h" #include "base/strings/string_number_conversions.h" #include "base/utf_string_conversions.h" @@ -80,8 +79,9 @@ GURL ToDataURL(const base::FilePath& path) { } std::vector<base::FilePath> ListFolder(const base::FilePath path) { - base::FileEnumerator files(path, false, - base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); + file_util::FileEnumerator files(path, false, + file_util::FileEnumerator::DIRECTORIES + | file_util::FileEnumerator::FILES); std::vector<base::FilePath> paths; for (base::FilePath current_path = files.Next(); !current_path.empty(); diff --git a/chrome/browser/extensions/api/serial/serial_port_enumerator_posix.cc b/chrome/browser/extensions/api/serial/serial_port_enumerator_posix.cc index 505d8b0..ce29ea5 100644 --- a/chrome/browser/extensions/api/serial/serial_port_enumerator_posix.cc +++ b/chrome/browser/extensions/api/serial/serial_port_enumerator_posix.cc @@ -5,7 +5,6 @@ #include "chrome/browser/extensions/api/serial/serial_port_enumerator.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/string_util.h" #include "content/public/browser/browser_thread.h" @@ -68,12 +67,13 @@ SerialPortEnumerator::GenerateValidSerialPortNames() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); const base::FilePath kDevRoot("/dev"); const int kFilesAndSymLinks = - base::FileEnumerator::FILES | - base::FileEnumerator::SHOW_SYM_LINKS; + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::SHOW_SYM_LINKS; StringSet valid_patterns = GenerateValidPatterns(); StringSet name_set; - base::FileEnumerator enumerator(kDevRoot, false, kFilesAndSymLinks); + file_util::FileEnumerator enumerator( + kDevRoot, false, kFilesAndSymLinks); do { const base::FilePath next_device_path(enumerator.Next()); const std::string next_device = next_device_path.value(); diff --git a/chrome/browser/extensions/api/storage/settings_backend.cc b/chrome/browser/extensions/api/storage/settings_backend.cc index 26a15629..369446a 100644 --- a/chrome/browser/extensions/api/storage/settings_backend.cc +++ b/chrome/browser/extensions/api/storage/settings_backend.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/api/storage/settings_backend.h" -#include "base/files/file_enumerator.h" +#include "base/file_util.h" #include "base/logging.h" #include "chrome/browser/extensions/api/storage/settings_sync_processor.h" #include "chrome/browser/extensions/api/storage/settings_sync_util.h" @@ -105,10 +105,13 @@ std::set<std::string> SettingsBackend::GetKnownExtensionIDs() const { } // Leveldb databases are directories inside base_path_. - base::FileEnumerator extension_dirs( - base_path_, false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator::FindInfo find_info; + file_util::FileEnumerator extension_dirs( + base_path_, false, file_util::FileEnumerator::DIRECTORIES); while (!extension_dirs.Next().empty()) { - base::FilePath extension_dir = extension_dirs.GetInfo().GetName(); + extension_dirs.GetFindInfo(&find_info); + base::FilePath extension_dir( + file_util::FileEnumerator::GetFilename(find_info)); DCHECK(!extension_dir.IsAbsolute()); // Extension IDs are created as std::strings so they *should* be ASCII. std::string maybe_as_ascii(extension_dir.MaybeAsASCII()); diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index b070653..7a79998 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -13,7 +13,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_reader.h" @@ -1318,8 +1317,8 @@ TEST_F(ExtensionServiceTest, CleanupOnStartup) { // Wait for GarbageCollectExtensions task to complete. loop_.RunUntilIdle(); - base::FileEnumerator dirs(extensions_install_dir_, false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator dirs(extensions_install_dir_, false, + file_util::FileEnumerator::DIRECTORIES); size_t count = 0; while (!dirs.Next().empty()) count++; diff --git a/chrome/browser/extensions/external_pref_loader.cc b/chrome/browser/extensions/external_pref_loader.cc index 46eeb0d..32cb24c 100644 --- a/chrome/browser/extensions/external_pref_loader.cc +++ b/chrome/browser/extensions/external_pref_loader.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_string_value_serializer.h" @@ -36,10 +35,10 @@ std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( return external_extension_paths; } - base::FileEnumerator json_files( + file_util::FileEnumerator json_files( external_extension_search_path, false, // Recursive. - base::FileEnumerator::FILES); + file_util::FileEnumerator::FILES); #if defined(OS_WIN) base::FilePath::StringType extension = UTF8ToWide(std::string(".json")); #elif defined(OS_POSIX) diff --git a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc index 968d13a..ddb56c01 100644 --- a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc +++ b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" #include "base/message_loop.h" @@ -133,10 +132,10 @@ class SandboxedUnpackerTest : public testing::Test { bool TempFilesRemoved() { // Check that temporary files were cleaned up. - int files_and_dirs = base::FileEnumerator::DIRECTORIES | - base::FileEnumerator::FILES; + int files_and_dirs = file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::FILES; - base::FileEnumerator temp_iterator( + file_util::FileEnumerator temp_iterator( temp_path_, true, // recursive files_and_dirs diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc index e4d5093..48cf490 100644 --- a/chrome/browser/file_select_helper.cc +++ b/chrome/browser/file_select_helper.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/platform_file.h" #include "base/string_util.h" #include "base/strings/string_split.h" @@ -220,7 +219,7 @@ void FileSelectHelper::OnListFile( // Directory upload returns directories via a "." file, so that // empty directories are included. This util call just checks // the flags in the structure; there's no file I/O going on. - if (data.info.IsDirectory()) + if (file_util::FileEnumerator::IsDirectory(data.info)) entry->results_.push_back(data.path.Append(FILE_PATH_LITERAL("."))); else entry->results_.push_back(data.path); diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc index d21cb0a..51cfaea 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.cc @@ -11,7 +11,6 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/message_loop.h" #include "chrome/browser/bookmarks/bookmark_service.h" @@ -755,8 +754,8 @@ void ExpireHistoryBackend::DoExpireHistoryIndexFiles() { base::FilePath::StringType history_index_files_pattern = TextDatabase::file_base(); history_index_files_pattern.append(FILE_PATH_LITERAL("*")); - base::FileEnumerator file_enumerator( - text_db_->GetDir(), false, base::FileEnumerator::FILES, + file_util::FileEnumerator file_enumerator( + text_db_->GetDir(), false, file_util::FileEnumerator::FILES, history_index_files_pattern); for (base::FilePath file = file_enumerator.Next(); !file.empty(); file = file_enumerator.Next()) { diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc index 1696610..97f6555 100644 --- a/chrome/browser/history/text_database_manager.cc +++ b/chrome/browser/history/text_database_manager.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/metrics/histogram.h" #include "base/logging.h" #include "base/message_loop.h" @@ -161,8 +160,8 @@ void TextDatabaseManager::InitDBList() { // Find files on disk matching our pattern so we can quickly test for them. base::FilePath::StringType filepattern(TextDatabase::file_base()); filepattern.append(FILE_PATH_LITERAL("*")); - base::FileEnumerator enumerator( - dir_, false, base::FileEnumerator::FILES, filepattern); + file_util::FileEnumerator enumerator( + dir_, false, file_util::FileEnumerator::FILES, filepattern); base::FilePath cur_file; while (!(cur_file = enumerator.Next()).empty()) { // Convert to the number representing this file. diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 72ce2c6..9d70c53 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -8,7 +8,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/i18n/icu_string_conversions.h" #include "base/message_loop.h" @@ -625,9 +624,9 @@ void Firefox2Importer::HTMLUnescape(string16* text) { void Firefox2Importer::FindXMLFilesInDir( const base::FilePath& dir, std::vector<base::FilePath>* xml_files) { - base::FileEnumerator file_enum(dir, false, - base::FileEnumerator::FILES, - FILE_PATH_LITERAL("*.xml")); + file_util::FileEnumerator file_enum(dir, false, + file_util::FileEnumerator::FILES, + FILE_PATH_LITERAL("*.xml")); base::FilePath file(file_enum.Next()); while (!file.empty()) { xml_files->push_back(file); diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 03fa5e2..2cab2ca 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -7,7 +7,6 @@ #include <set> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/stl_util.h" @@ -420,7 +419,8 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( #endif // Get search engine definition from file system. - base::FileEnumerator engines(app_path, false, base::FileEnumerator::FILES); + file_util::FileEnumerator engines(app_path, false, + file_util::FileEnumerator::FILES); for (base::FilePath engine_path = engines.Next(); !engine_path.value().empty(); engine_path = engines.Next()) { files->push_back(engine_path); diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 904f54e..bfcfd01 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -16,7 +16,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/string16.h" #include "base/string_util.h" @@ -817,8 +816,8 @@ void IEImporter::ParseFavoritesFolder( // Favorites path length. Make sure it doesn't include the trailing \. size_t favorites_path_len = favorites_path.StripTrailingSeparators().value().size(); - base::FileEnumerator file_enumerator( - favorites_path, true, base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator( + favorites_path, true, file_util::FileEnumerator::FILES); while (!(file = file_enumerator.Next()).value().empty() && !cancelled()) file_list.push_back(file.value()); diff --git a/chrome/browser/policy/config_dir_policy_loader.cc b/chrome/browser/policy/config_dir_policy_loader.cc index 56b079d..572a82d 100644 --- a/chrome/browser/policy/config_dir_policy_loader.cc +++ b/chrome/browser/policy/config_dir_policy_loader.cc @@ -11,7 +11,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_reader.h" #include "base/logging.h" @@ -101,8 +100,8 @@ base::Time ConfigDirPolicyLoader::LastModificationTime() { continue; // Enumerate the files and find the most recent modification timestamp. - base::FileEnumerator file_enumerator(path, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator(path, false, + file_util::FileEnumerator::FILES); for (base::FilePath config_file = file_enumerator.Next(); !config_file.empty(); config_file = file_enumerator.Next()) { @@ -119,8 +118,8 @@ void ConfigDirPolicyLoader::LoadFromPath(const base::FilePath& path, PolicyBundle* bundle) { // Enumerate the files and sort them lexicographically. std::set<base::FilePath> files; - base::FileEnumerator file_enumerator(path, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator(path, false, + file_util::FileEnumerator::FILES); for (base::FilePath config_file_path = file_enumerator.Next(); !config_file_path.empty(); config_file_path = file_enumerator.Next()) files.insert(config_file_path); diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 841f9d9..3a7a78d 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -10,7 +10,6 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" @@ -278,7 +277,8 @@ void DownloadAndVerifyFile( EXPECT_EQ( 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE)); EXPECT_TRUE(file_util::PathExists(downloaded)); - base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator( + dir, false, file_util::FileEnumerator::FILES); EXPECT_EQ(file, enumerator.Next().BaseName()); EXPECT_EQ(base::FilePath(), enumerator.Next()); } @@ -287,9 +287,9 @@ void DownloadAndVerifyFile( int CountScreenshots() { DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); - base::FileEnumerator enumerator(download_prefs->DownloadPath(), - false, base::FileEnumerator::FILES, - "Screenshot*"); + file_util::FileEnumerator enumerator(download_prefs->DownloadPath(), + false, file_util::FileEnumerator::FILES, + "Screenshot*"); int count = 0; while (!enumerator.Next().empty()) count++; diff --git a/chrome/browser/printing/printing_layout_browsertest.cc b/chrome/browser/printing/printing_layout_browsertest.cc index 23ee6a7..2e00618 100644 --- a/chrome/browser/printing/printing_layout_browsertest.cc +++ b/chrome/browser/printing/printing_layout_browsertest.cc @@ -4,7 +4,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/message_loop.h" #include "base/path_service.h" @@ -196,8 +195,8 @@ class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>, bool found_emf = false; bool found_prn = false; for (int i = 0; i < 100; ++i) { - base::FileEnumerator enumerator(emf_path_, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(emf_path_, false, + file_util::FileEnumerator::FILES); emf_file.clear(); prn_file.clear(); found_emf = false; diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 12ae9e3..a1ed001 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "base/deferred_sequenced_task_runner.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/metrics/histogram.h" #include "base/prefs/pref_registry_simple.h" @@ -95,10 +94,14 @@ std::vector<base::FilePath>& ProfilesToDelete() { int64 ComputeFilesSize(const base::FilePath& directory, const base::FilePath::StringType& pattern) { int64 running_size = 0; - base::FileEnumerator iter(directory, false, base::FileEnumerator::FILES, - pattern); - while (!iter.Next().empty()) - running_size += iter.GetInfo().GetSize(); + file_util::FileEnumerator iter(directory, false, + file_util::FileEnumerator::FILES, + pattern); + while (!iter.Next().empty()) { + file_util::FileEnumerator::FindInfo info; + iter.GetFindInfo(&info); + running_size += file_util::FileEnumerator::GetFilesize(info); + } return running_size; } diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc index d0b0b94..92ac0ea 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc @@ -12,7 +12,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/path_service.h" #include "base/string16.h" #include "base/string_util.h" @@ -233,8 +232,8 @@ void ListDesktopShortcutsWithCommandLine(const base::FilePath& chrome_exe, if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL)) return; - base::FileEnumerator enumerator(user_shortcuts_directory, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(user_shortcuts_directory, false, + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.empty(); path = enumerator.Next()) { string16 shortcut_command_line; @@ -400,8 +399,8 @@ bool ChromeDesktopShortcutsExist(const base::FilePath& chrome_exe) { if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL)) return false; - base::FileEnumerator enumerator(user_shortcuts_directory, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(user_shortcuts_directory, false, + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.empty(); path = enumerator.Next()) { if (IsChromeShortcut(path, chrome_exe, NULL)) diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index c73fc2c..fb1bd64 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -11,7 +11,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/string_util.h" @@ -393,9 +392,9 @@ int ShellIntegration::MigrateShortcutsInPathInternal( DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN7); // Enumerate all pinned shortcuts in the given path directly. - base::FileEnumerator shortcuts_enum( + file_util::FileEnumerator shortcuts_enum( path, false, // not recursive - base::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk")); + file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk")); bool is_per_user_install = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); diff --git a/chrome/browser/ui/pdf/pdf_browsertest.cc b/chrome/browser/ui/pdf/pdf_browsertest.cc index fe95498..f73fefb 100644 --- a/chrome/browser/ui/pdf/pdf_browsertest.cc +++ b/chrome/browser/ui/pdf/pdf_browsertest.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/hash.h" #include "base/path_service.h" #include "base/string_util.h" @@ -315,10 +314,10 @@ IN_PROC_BROWSER_TEST_P(PDFBrowserTest, Loading) { content::Source<NavigationController>(controller)); std::string base_url = std::string("files/"); - base::FileEnumerator file_enumerator( + file_util::FileEnumerator file_enumerator( ui_test_utils::GetTestFilePath(GetPDFTestDir(), base::FilePath()), false, - base::FileEnumerator::FILES, + file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.pdf")); for (base::FilePath file_path = file_enumerator.Next(); !file_path.empty(); diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index 90a2ca9..6483cd7 100644 --- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/format_macros.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" @@ -61,22 +60,26 @@ namespace { void GetGCacheContents(const base::FilePath& root_path, base::ListValue* gcache_contents, base::DictionaryValue* gcache_summary) { + using file_util::FileEnumerator; // Use this map to sort the result list by the path. std::map<base::FilePath, DictionaryValue*> files; - const int options = (base::FileEnumerator::FILES | - base::FileEnumerator::DIRECTORIES | - base::FileEnumerator::SHOW_SYM_LINKS); - base::FileEnumerator enumerator(root_path, true /* recursive */, options); + const int options = (file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::SHOW_SYM_LINKS); + FileEnumerator enumerator(root_path, true /* recursive */, options); int64 total_size = 0; for (base::FilePath current = enumerator.Next(); !current.empty(); current = enumerator.Next()) { - base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); - int64 size = find_info.GetSize(); - const bool is_directory = find_info.IsDirectory(); - const bool is_symbolic_link = file_util::IsLink(find_info.GetName()); - const base::Time last_modified = find_info.GetLastModifiedTime(); + FileEnumerator::FindInfo find_info; + enumerator.GetFindInfo(&find_info); + int64 size = FileEnumerator::GetFilesize(find_info); + const bool is_directory = FileEnumerator::IsDirectory(find_info); + const bool is_symbolic_link = + file_util::IsLink(FileEnumerator::GetFilename(find_info)); + const base::Time last_modified = + FileEnumerator::GetLastModifiedTime(find_info); base::DictionaryValue* entry = new base::DictionaryValue; entry->SetString("path", current.value()); @@ -90,7 +93,7 @@ void GetGCacheContents(const base::FilePath& root_path, // Print lower 9 bits in octal format. entry->SetString( "permission", - base::StringPrintf("%03o", find_info.stat().st_mode & 0x1ff)); + base::StringPrintf("%03o", find_info.stat.st_mode & 0x1ff)); files[current] = entry; total_size += size; diff --git a/chrome/browser/ui/webui/feedback_ui.cc b/chrome/browser/ui/webui/feedback_ui.cc index 30b12d0..1d09ab9 100644 --- a/chrome/browser/ui/webui/feedback_ui.cc +++ b/chrome/browser/ui/webui/feedback_ui.cc @@ -10,7 +10,6 @@ #include "base/base64.h" #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" @@ -705,8 +704,9 @@ void FeedbackUI::GetMostRecentScreenshots( std::string pattern = std::string(ScreenshotSource::kScreenshotPrefix) + "*" + ScreenshotSource::kScreenshotSuffix; - base::FileEnumerator screenshots(filepath, false, - base::FileEnumerator::FILES, pattern); + file_util::FileEnumerator screenshots(filepath, false, + file_util::FileEnumerator::FILES, + pattern); base::FilePath screenshot = screenshots.Next(); std::vector<std::string> screenshot_filepaths; diff --git a/chrome/common/extensions/api/i18n/default_locale_handler.cc b/chrome/common/extensions/api/i18n/default_locale_handler.cc index 7221b8f..a8cd544 100644 --- a/chrome/common/extensions/api/i18n/default_locale_handler.cc +++ b/chrome/common/extensions/api/i18n/default_locale_handler.cc @@ -5,7 +5,6 @@ #include "chrome/common/extensions/api/i18n/default_locale_handler.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/memory/scoped_ptr.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -72,7 +71,9 @@ bool DefaultLocaleHandler::Validate( } // Treat all folders under _locales as valid locales. - base::FileEnumerator locales(path, false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator locales(path, + false, + file_util::FileEnumerator::DIRECTORIES); std::set<std::string> all_locales; extension_l10n_util::GetAllLocales(&all_locales); diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index d277b47..566779b 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -8,7 +8,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_file_value_serializer.h" @@ -203,8 +202,8 @@ std::vector<base::FilePath> FindPrivateKeyFiles( const base::FilePath& extension_dir) { std::vector<base::FilePath> result; // Pattern matching only works at the root level, so filter manually. - base::FileEnumerator traversal(extension_dir, /*recursive=*/true, - base::FileEnumerator::FILES); + file_util::FileEnumerator traversal(extension_dir, /*recursive=*/true, + file_util::FileEnumerator::FILES); for (base::FilePath current = traversal.Next(); !current.empty(); current = traversal.Next()) { if (!current.MatchesExtension(chrome::kExtensionKeyFileExtension)) @@ -332,9 +331,9 @@ void GarbageCollectExtensions( return; DVLOG(1) << "Garbage collecting extensions..."; - base::FileEnumerator enumerator(install_directory, - false, // Not recursive. - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator enumerator(install_directory, + false, // Not recursive. + file_util::FileEnumerator::DIRECTORIES); base::FilePath extension_path; for (extension_path = enumerator.Next(); !extension_path.value().empty(); extension_path = enumerator.Next()) { @@ -379,10 +378,10 @@ void GarbageCollectExtensions( } // Clean up old version directories. - base::FileEnumerator versions_enumerator( + file_util::FileEnumerator versions_enumerator( extension_path, false, // Not recursive. - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath version_dir = versions_enumerator.Next(); !version_dir.value().empty(); version_dir = versions_enumerator.Next()) { @@ -472,8 +471,9 @@ bool CheckForIllegalFilenames(const base::FilePath& extension_path, // There is a problem when using pattern "_*" with FileEnumerator, so we have // to cheat with find_first_of and match all. const int kFilesAndDirectories = - base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES; - base::FileEnumerator all_files(extension_path, false, kFilesAndDirectories); + file_util::FileEnumerator::DIRECTORIES | file_util::FileEnumerator::FILES; + file_util::FileEnumerator all_files( + extension_path, false, kFilesAndDirectories); base::FilePath file; while (!(file = all_files.Next()).empty()) { diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index add1354..d2dada0 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -10,7 +10,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/json/json_file_value_serializer.h" #include "base/logging.h" #include "base/memory/linked_ptr.h" @@ -287,9 +286,9 @@ bool GetValidLocales(const base::FilePath& locale_path, GetAllLocales(&chrome_locales); // Enumerate all supplied locales in the extension. - base::FileEnumerator locales(locale_path, - false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator locales(locale_path, + false, + file_util::FileEnumerator::DIRECTORIES); base::FilePath locale_folder; while (!(locale_folder = locales.Next()).empty()) { std::string locale_name = locale_folder.BaseName().MaybeAsASCII(); diff --git a/chrome/common/extensions/unpacker.cc b/chrome/common/extensions/unpacker.cc index b326f46..0cf8d94 100644 --- a/chrome/common/extensions/unpacker.cc +++ b/chrome/common/extensions/unpacker.cc @@ -7,7 +7,6 @@ #include <set> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/i18n/rtl.h" #include "base/json/json_file_value_serializer.h" @@ -128,9 +127,9 @@ bool Unpacker::ReadAllMessageCatalogs(const std::string& default_locale) { temp_install_dir_.Append(kLocaleFolder); // Not all folders under _locales have to be valid locales. - base::FileEnumerator locales(locales_path, - false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator locales(locales_path, + false, + file_util::FileEnumerator::DIRECTORIES); std::set<std::string> all_locales; extension_l10n_util::GetAllLocales(&all_locales); diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index 8b94c01..9f112c0 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/process_util.h" @@ -125,8 +124,8 @@ int ApplyDiffPatch(const base::FilePath& src, Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); Version* version = NULL; - base::FileEnumerator version_enum(chrome_path, false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator version_enum(chrome_path, false, + file_util::FileEnumerator::DIRECTORIES); // TODO(tommi): The version directory really should match the version of // setup.exe. To begin with, we should at least DCHECK that that's true. @@ -134,11 +133,12 @@ Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { bool version_found = false; while (!version_enum.Next().empty()) { - base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); - VLOG(1) << "directory found: " << find_data.GetName().value(); + file_util::FileEnumerator::FindInfo find_data = {0}; + version_enum.GetFindInfo(&find_data); + VLOG(1) << "directory found: " << find_data.cFileName; scoped_ptr<Version> found_version( - new Version(WideToASCII(find_data.GetName().value()))); + new Version(WideToASCII(find_data.cFileName))); if (found_version->IsValid() && found_version->CompareTo(*max_version.get()) > 0) { max_version.reset(found_version.release()); diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 27bb823..295028c 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -11,7 +11,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/path_service.h" #include "base/process_util.h" #include "base/string16.h" @@ -253,10 +252,11 @@ void CheckShouldRemoveSetupAndArchive( // Returns false in case of an error. bool RemoveInstallerFiles(const base::FilePath& installer_directory, bool remove_setup) { - base::FileEnumerator file_enumerator( + using file_util::FileEnumerator; + FileEnumerator file_enumerator( installer_directory, false, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + FileEnumerator::FILES | FileEnumerator::DIRECTORIES); bool success = true; base::FilePath setup_exe_base_name(installer::kSetupExe); @@ -572,8 +572,9 @@ DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, // directory. For parents of the installer directory, we will later recurse // and delete all the children (that are not also parents/children of the // installer directory). - base::FileEnumerator file_enumerator(target_path, true, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + using file_util::FileEnumerator; + FileEnumerator file_enumerator( + target_path, true, FileEnumerator::FILES | FileEnumerator::DIRECTORIES); while (true) { base::FilePath to_delete(file_enumerator.Next()); if (to_delete.empty()) @@ -594,8 +595,9 @@ DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, // We don't try killing Chrome processes for Chrome Frame builds since // that is unlikely to help. Instead, schedule files for deletion and // return a value that will trigger a reboot prompt. - base::FileEnumerator::FileInfo find_info = file_enumerator.GetInfo(); - if (find_info.IsDirectory()) + FileEnumerator::FindInfo find_info; + file_enumerator.GetFindInfo(&find_info); + if (FileEnumerator::IsDirectory(find_info)) ScheduleDirectoryForDeletion(to_delete.value().c_str()); else ScheduleFileSystemEntityForDeletion(to_delete.value().c_str()); diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc index 8222ba9..7811be4 100644 --- a/chrome/installer/test/alternate_version_generator.cc +++ b/chrome/installer/test/alternate_version_generator.cc @@ -34,7 +34,6 @@ #include "base/basictypes.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" @@ -433,7 +432,8 @@ bool ApplyAlternateVersion(const base::FilePath& work_dir, // Modify all .dll and .exe files with the current version. bool doing_great = true; - base::FileEnumerator all_files(work_dir, true, base::FileEnumerator::FILES); + file_util::FileEnumerator all_files(work_dir, true, + file_util::FileEnumerator::FILES); do { base::FilePath file = all_files.Next(); if (file.empty()) { diff --git a/chrome/installer/util/delete_after_reboot_helper.cc b/chrome/installer/util/delete_after_reboot_helper.cc index 3fff620..cc76b0e 100644 --- a/chrome/installer/util/delete_after_reboot_helper.cc +++ b/chrome/installer/util/delete_after_reboot_helper.cc @@ -16,7 +16,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/win/registry.h" #include "base/string_util.h" @@ -117,8 +116,8 @@ bool ScheduleDirectoryForDeletion(const wchar_t* dir_name) { // First schedule all the normal files for deletion. { bool success = true; - base::FileEnumerator file_enum(base::FilePath(dir_name), false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_enum(base::FilePath(dir_name), false, + file_util::FileEnumerator::FILES); for (base::FilePath file = file_enum.Next(); !file.empty(); file = file_enum.Next()) { success = ScheduleFileSystemEntityForDeletion(file.value().c_str()); @@ -132,8 +131,8 @@ bool ScheduleDirectoryForDeletion(const wchar_t* dir_name) { // Then recurse to all the subdirectories. { bool success = true; - base::FileEnumerator dir_enum(base::FilePath(dir_name), false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator dir_enum(base::FilePath(dir_name), false, + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath sub_dir = dir_enum.Next(); !sub_dir.empty(); sub_dir = dir_enum.Next()) { success = ScheduleDirectoryForDeletion(sub_dir.value().c_str()); diff --git a/chrome/installer/util/duplicate_tree_detector.cc b/chrome/installer/util/duplicate_tree_detector.cc index 62d9b51..ff4df32 100644 --- a/chrome/installer/util/duplicate_tree_detector.cc +++ b/chrome/installer/util/duplicate_tree_detector.cc @@ -6,13 +6,13 @@ #include "chrome/installer/util/duplicate_tree_detector.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" namespace installer { bool IsIdenticalFileHierarchy(const base::FilePath& src_path, const base::FilePath& dest_path) { + using file_util::FileEnumerator; base::PlatformFileInfo src_info; base::PlatformFileInfo dest_info; @@ -35,8 +35,8 @@ bool IsIdenticalFileHierarchy(const base::FilePath& src_path, // "identical" to all the entries in src_path. is_identical = true; - base::FileEnumerator path_enum(src_path, false /* not recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + FileEnumerator path_enum(src_path, false /* not recursive */, + FileEnumerator::FILES | FileEnumerator::DIRECTORIES); for (base::FilePath path = path_enum.Next(); is_identical && !path.empty(); path = path_enum.Next()) { diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index b3ccfc3..0090629 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -11,7 +11,6 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/file_version_info.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/string_util.h" @@ -650,8 +649,8 @@ void InstallerState::RemoveOldVersionDirectories( GetExistingExeVersions(&existing_version_strings); // Try to delete all directories that are not in the set we care to keep. - base::FileEnumerator version_enum(target_path(), false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator version_enum(target_path(), false, + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); next_version = version_enum.Next()) { base::FilePath dir_name(next_version.BaseName()); diff --git a/chrome/installer/util/installer_state_unittest.cc b/chrome/installer/util/installer_state_unittest.cc index f07564c..0f985f8 100644 --- a/chrome/installer/util/installer_state_unittest.cc +++ b/chrome/installer/util/installer_state_unittest.cc @@ -9,7 +9,6 @@ #include "base/base_paths.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" @@ -585,8 +584,8 @@ TEST_F(InstallerStateTest, RemoveOldVersionDirs) { expected_remaining_dirs.insert(kNewChromeExeVersion); // Enumerate dirs in target_path(), ensure only desired remain. - base::FileEnumerator version_enum(installer_state.target_path(), false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator version_enum(installer_state.target_path(), false, + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); next_version = version_enum.Next()) { base::FilePath dir_name(next_version.BaseName()); diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 611aeb2..273c7f0 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -18,7 +18,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/logging.h" @@ -1232,8 +1231,8 @@ bool BatchShortcutAction(const FileOperationCallback& shortcut_operation, bool success = true; InstallUtil::ProgramCompare target_compare(target_exe); - base::FileEnumerator enumerator( - shortcut_folder, false, base::FileEnumerator::FILES, + file_util::FileEnumerator enumerator( + shortcut_folder, false, file_util::FileEnumerator::FILES, string16(L"*") + installer::kLnkExt); base::FilePath target_path; for (base::FilePath shortcut_path = enumerator.Next(); diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc index db38ed8..aa3d8e9 100644 --- a/chrome/installer/util/shell_util_unittest.cc +++ b/chrome/installer/util/shell_util_unittest.cc @@ -9,7 +9,6 @@ #include "base/base_paths.h" #include "base/base_paths_win.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/md5.h" #include "base/memory/scoped_ptr.h" @@ -527,8 +526,8 @@ TEST_F(ShellUtilShortcutTest, CreateMultipleStartMenuShortcutsAndRemoveFolder) { base::FilePath shortcut_folder( fake_start_menu_.path().Append(dist_->GetAppShortCutName())); - base::FileEnumerator file_counter(shortcut_folder, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_counter(shortcut_folder, false, + file_util::FileEnumerator::FILES); int count = 0; while (!file_counter.Next().empty()) ++count; diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index 9619ced..8a932b5 100644 --- a/chrome/test/automation/proxy_launcher.cc +++ b/chrome/test/automation/proxy_launcher.cc @@ -8,7 +8,6 @@ #include "base/environment.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/stringprintf.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" @@ -50,11 +49,13 @@ const char kUITestType[] = "ui"; // startup tests other than the "cold" ones run more slowly than necessary. bool CopyDirectoryContentsNoCache(const base::FilePath& source, const base::FilePath& dest) { - base::FileEnumerator en(source, false, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator en(source, false, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath cur = en.Next(); !cur.empty(); cur = en.Next()) { - base::FileEnumerator::FileInfo info = en.GetInfo(); - if (info.IsDirectory()) { + file_util::FileEnumerator::FindInfo info; + en.GetFindInfo(&info); + if (file_util::FileEnumerator::IsDirectory(info)) { if (!file_util::CopyDirectory(cur, dest, true)) return false; } else { @@ -66,7 +67,8 @@ bool CopyDirectoryContentsNoCache(const base::FilePath& source, // Kick out the profile files, this must happen after SetUp which creates the // profile. It might be nicer to use EvictFileFromSystemCacheWrapper from // UITest which will retry on failure. - base::FileEnumerator kickout(dest, true, base::FileEnumerator::FILES); + file_util::FileEnumerator kickout(dest, true, + file_util::FileEnumerator::FILES); for (base::FilePath cur = kickout.Next(); !cur.empty(); cur = kickout.Next()) base::EvictFileFromSystemCacheWithRetry(cur); return true; diff --git a/chrome/test/chromedriver/chrome/zip.cc b/chrome/test/chromedriver/chrome/zip.cc index d717bf5..cbebc20 100644 --- a/chrome/test/chromedriver/chrome/zip.cc +++ b/chrome/test/chromedriver/chrome/zip.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/string16.h" #include "base/string_util.h" @@ -138,8 +137,9 @@ bool ZipWithFilterCallback(const base::FilePath& src_dir, } bool success = true; - base::FileEnumerator file_enumerator(src_dir, true /* recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator file_enumerator(src_dir, true /* recursive */, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { if (!filter_cb.Run(path)) { diff --git a/chrome/test/chromedriver/util.cc b/chrome/test/chromedriver/util.cc index e4907b1..60919ab 100644 --- a/chrome/test/chromedriver/util.cc +++ b/chrome/test/chromedriver/util.cc @@ -6,7 +6,6 @@ #include "base/base64.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" #include "base/rand_util.h" @@ -384,8 +383,9 @@ Status UnzipSoleFile(const base::FilePath& unzip_dir, } } - base::FileEnumerator enumerator(unzip_dir, false /* recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator enumerator(unzip_dir, false /* recursive */, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES); base::FilePath first_file = enumerator.Next(); if (first_file.empty()) return Status(kUnknownError, "contained 0 files"); diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc index 82e997e..1752713 100644 --- a/chrome/test/gpu/gpu_pixel_browsertest.cc +++ b/chrome/test/gpu/gpu_pixel_browsertest.cc @@ -4,7 +4,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/path_service.h" #include "base/string_util.h" @@ -421,10 +420,10 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { void ObtainLocalRefImageRevision() { base::FilePath filter; filter = filter.AppendASCII(test_name_ + "_*.rev"); - base::FileEnumerator locator(ref_img_dir_, - false, // non recursive - base::FileEnumerator::FILES, - filter.value()); + file_util::FileEnumerator locator(ref_img_dir_, + false, // non recursive + file_util::FileEnumerator::FILES, + filter.value()); int64 max_revision = 0; std::vector<base::FilePath> outdated_revs; for (base::FilePath full_path = locator.Next(); diff --git a/chrome/test/mini_installer_test/installer_path_provider.cc b/chrome/test/mini_installer_test/installer_path_provider.cc index b751153..02f7abe 100644 --- a/chrome/test/mini_installer_test/installer_path_provider.cc +++ b/chrome/test/mini_installer_test/installer_path_provider.cc @@ -8,7 +8,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/path_service.h" #include "base/process_util.h" #include "base/string_util.h" @@ -20,12 +19,24 @@ namespace { struct FilePathInfo { - base::FileEnumerator::FileInfo info; + file_util::FileEnumerator::FindInfo info; base::FilePath path; }; -bool CompareDate(const FilePathInfo& a, const FilePathInfo& b) { - return a.info.GetLastModifiedTime() > b.info.GetLastModifiedTime(); +bool CompareDate(const FilePathInfo& a, + const FilePathInfo& b) { +#if defined(OS_POSIX) + return a.info.stat.st_mtime > b.info.stat.st_mtime; +#elif defined(OS_WIN) + if (a.info.ftLastWriteTime.dwHighDateTime == + b.info.ftLastWriteTime.dwHighDateTime) { + return a.info.ftLastWriteTime.dwLowDateTime > + b.info.ftLastWriteTime.dwLowDateTime; + } else { + return a.info.ftLastWriteTime.dwHighDateTime > + b.info.ftLastWriteTime.dwHighDateTime; + } +#endif } // Get list of file |type| matching |pattern| in |root|. @@ -33,15 +44,15 @@ bool CompareDate(const FilePathInfo& a, const FilePathInfo& b) { // Return true if files/directories are found. bool FindMatchingFiles(const base::FilePath& root, const std::string& pattern, - base::FileEnumerator::FileType type, + file_util::FileEnumerator::FileType type, std::vector<base::FilePath>* paths) { - base::FileEnumerator files(root, false, type, + file_util::FileEnumerator files(root, false, type, base::FilePath().AppendASCII(pattern).value()); std::vector<FilePathInfo> matches; for (base::FilePath current = files.Next(); !current.empty(); current = files.Next()) { FilePathInfo entry; - entry.info = files.GetInfo(); + files.GetFindInfo(&entry.info); entry.path = current; matches.push_back(entry); } @@ -59,7 +70,7 @@ bool FindMatchingFiles(const base::FilePath& root, bool FindNewestMatchingFile(const base::FilePath& root, const std::string& pattern, - base::FileEnumerator::FileType type, + file_util::FileEnumerator::FileType type, base::FilePath* path) { std::vector<base::FilePath> paths; if (FindMatchingFiles(root, pattern, type, &paths)) { @@ -133,12 +144,12 @@ bool InstallerPathProvider::GetPreviousInstaller(base::FilePath* path) { "*%s", tokenized_name[2].c_str()); std::vector<base::FilePath> previous_build; if (FindMatchingFiles(diff_installer.DirName().DirName().DirName(), - build_pattern, base::FileEnumerator::DIRECTORIES, + build_pattern, file_util::FileEnumerator::DIRECTORIES, &previous_build)) { base::FilePath windir = previous_build.at(0).Append( mini_installer_constants::kWinFolder); FindNewestMatchingFile(windir, full_installer_pattern, - base::FileEnumerator::FILES, &previous_installer); + file_util::FileEnumerator::FILES, &previous_installer); } if (previous_installer.empty()) @@ -204,7 +215,7 @@ bool InstallerPathProvider::GetInstaller(const std::string& pattern, base::FilePath root(mini_installer_constants::kChromeInstallersLocation); std::vector<base::FilePath> paths; if (!FindMatchingFiles(root, current_build_, - base::FileEnumerator::DIRECTORIES, &paths)) { + file_util::FileEnumerator::DIRECTORIES, &paths)) { return false; } @@ -212,8 +223,8 @@ bool InstallerPathProvider::GetInstaller(const std::string& pattern, for (dir = paths.begin(); dir != paths.end(); ++dir) { base::FilePath windir = dir->Append( mini_installer_constants::kWinFolder); - if (FindNewestMatchingFile(windir, pattern, base::FileEnumerator::FILES, - &installer)) { + if (FindNewestMatchingFile(windir, pattern, + file_util::FileEnumerator::FILES, &installer)) { break; } } diff --git a/chrome/test/perf/page_cycler_test.cc b/chrome/test/perf/page_cycler_test.cc index b386fdd..9d13000 100644 --- a/chrome/test/perf/page_cycler_test.cc +++ b/chrome/test/perf/page_cycler_test.cc @@ -5,7 +5,6 @@ #include "base/basictypes.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/path_service.h" #include "base/process_util.h" @@ -69,8 +68,8 @@ void PopulateBufferCache(const base::FilePath& test_dir) { const base::FilePath svn_dir(FILE_PATH_LITERAL(".svn")); for (size_t idx = 0; idx < dirs.size(); ++idx) { - base::FileEnumerator dir_enumerator(dirs[idx], false, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator dir_enumerator(dirs[idx], false, + file_util::FileEnumerator::DIRECTORIES); base::FilePath path; for (path = dir_enumerator.Next(); !path.empty(); @@ -90,8 +89,8 @@ void PopulateBufferCache(const base::FilePath& test_dir) { std::vector<base::FilePath>::const_iterator iter; for (iter = dirs.begin(); iter != dirs.end(); ++iter) { - base::FileEnumerator file_enumerator(*iter, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator(*iter, false, + file_util::FileEnumerator::FILES); base::FilePath path; for (path = file_enumerator.Next(); !path.empty(); diff --git a/chrome/test/perf/startup_test.cc b/chrome/test/perf/startup_test.cc index c5d2083..f8ab9f8 100644 --- a/chrome/test/perf/startup_test.cc +++ b/chrome/test/perf/startup_test.cc @@ -4,7 +4,6 @@ #include "base/environment.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/path_service.h" #include "base/string_util.h" #include "base/stringprintf.h" diff --git a/chrome/test/reliability/automated_ui_tests.cc b/chrome/test/reliability/automated_ui_tests.cc index 4ea9509..4654082 100644 --- a/chrome/test/reliability/automated_ui_tests.cc +++ b/chrome/test/reliability/automated_ui_tests.cc @@ -10,7 +10,6 @@ #include "base/environment.h" #include "base/file_util.h" #include "base/file_version_info.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/i18n/time_formatting.h" #include "base/logging.h" @@ -772,9 +771,9 @@ base::FilePath AutomatedUITest::GetMostRecentCrashDump() { bool first_file = true; - base::FileEnumerator enumerator(crash_dump_path, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(crash_dump_path, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { base::PlatformFileInfo file_info; diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index e3b546a..99429b8 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -41,7 +41,6 @@ #include "base/environment.h" #include "base/file_util.h" #include "base/file_version_info.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/i18n/time_formatting.h" #include "base/memory/scoped_ptr.h" @@ -637,9 +636,9 @@ class PageLoadTest : public UITest { PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); } - base::FileEnumerator enumerator(crash_dumps_dir_path_, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(crash_dumps_dir_path_, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp"))) @@ -688,9 +687,9 @@ class PageLoadTest : public UITest { } bool HasNewCrashDumps() { - base::FileEnumerator enumerator(crash_dumps_dir_path_, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(crash_dumps_dir_path_, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) && @@ -708,9 +707,9 @@ class PageLoadTest : public UITest { NavigationMetrics* metrics, bool delete_dumps) { int num_dumps = 0; - base::FileEnumerator enumerator(crash_dumps_dir_path_, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(crash_dumps_dir_path_, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) && diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index b471715..87c5679 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -17,7 +17,6 @@ #include "base/command_line.h" #include "base/environment.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_file_value_serializer.h" @@ -448,9 +447,11 @@ int UITestBase::GetCrashCount() const { PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); int files_found = 0; - base::FileEnumerator en(crash_dump_path, false, base::FileEnumerator::FILES); + file_util::FileEnumerator en(crash_dump_path, false, + file_util::FileEnumerator::FILES); while (!en.Next().empty()) { - if (en.GetInfo().GetLastModifiedTime() > test_start_time_) + file_util::FileEnumerator::FindInfo info; + if (file_util::FileEnumerator::GetLastModifiedTime(info) > test_start_time_) files_found++; } @@ -459,7 +460,7 @@ int UITestBase::GetCrashCount() const { return files_found / 2; #else return files_found; -#endif + #endif } std::string UITestBase::CheckErrorsAndCrashes() const { diff --git a/chrome/test/webdriver/webdriver_util.cc b/chrome/test/webdriver/webdriver_util.cc index 54833a8..274144c 100644 --- a/chrome/test/webdriver/webdriver_util.cc +++ b/chrome/test/webdriver/webdriver_util.cc @@ -7,7 +7,6 @@ #include "base/base64.h" #include "base/basictypes.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" #include "base/json/json_reader.h" @@ -373,8 +372,9 @@ bool UnzipSoleFile(const base::FilePath& unzip_dir, return false; } - base::FileEnumerator enumerator(unzip_dir, false /* recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator enumerator(unzip_dir, false /* recursive */, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES); base::FilePath first_file = enumerator.Next(); if (first_file.empty()) { *error_msg = "Zip contained 0 files"; diff --git a/chrome/tools/profiles/generate_profile.cc b/chrome/tools/profiles/generate_profile.cc index afb620e..fbd761e 100644 --- a/chrome/tools/profiles/generate_profile.cc +++ b/chrome/tools/profiles/generate_profile.cc @@ -10,7 +10,6 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/i18n/icu_util.h" #include "base/logging.h" @@ -291,8 +290,8 @@ int main(int argc, char* argv[]) { message_loop.RunUntilIdle(); - base::FileEnumerator file_iterator(profile.GetPath(), false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_iterator(profile.GetPath(), false, + file_util::FileEnumerator::FILES); base::FilePath path = file_iterator.Next(); while (!path.empty()) { base::FilePath dst_file = dst_dir.Append(path.BaseName()); diff --git a/chrome_frame/test/reliability/page_load_test.cc b/chrome_frame/test/reliability/page_load_test.cc index 07af04d..59212a6 100644 --- a/chrome_frame/test/reliability/page_load_test.cc +++ b/chrome_frame/test/reliability/page_load_test.cc @@ -25,7 +25,6 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/file_version_info.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/i18n/time_formatting.h" #include "base/path_service.h" @@ -333,9 +332,9 @@ class PageLoadTest : public testing::Test { virtual void SetUp() { // Initialize crash_dumps_dir_path_. PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); - base::FileEnumerator enumerator(crash_dumps_dir_path_, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(crash_dumps_dir_path_, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp"))) @@ -412,9 +411,9 @@ class PageLoadTest : public testing::Test { NavigationMetrics* metrics) { int num_dumps = 0; - base::FileEnumerator enumerator(crash_dumps_dir_path_, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(crash_dumps_dir_path_, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) && diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc index 9008285..c13228a 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc @@ -15,7 +15,6 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/path_service.h" #include "base/process.h" @@ -120,11 +119,14 @@ base::FilePath GetAppDataDir() { // Delete files which where not deleted by chrome. void DeleteLeakedFiles(const base::FilePath& dir) { + using file_util::FileEnumerator; base::Time delete_before = base::Time::Now() - base::TimeDelta::FromDays(1); - base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES); + FileEnumerator enumerator(dir, false, FileEnumerator::FILES); for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); file_path = enumerator.Next()) { - if (enumerator.GetInfo().GetLastModifiedTime() < delete_before) + FileEnumerator::FindInfo info; + enumerator.GetFindInfo(&info); + if (FileEnumerator::GetLastModifiedTime(info) < delete_before) file_util::Delete(file_path, false); } } diff --git a/cloud_print/virtual_driver/win/virtual_driver.gypi b/cloud_print/virtual_driver/win/virtual_driver.gypi index 26dc308..80c0ffb 100644 --- a/cloud_print/virtual_driver/win/virtual_driver.gypi +++ b/cloud_print/virtual_driver/win/virtual_driver.gypi @@ -35,7 +35,6 @@ 'port_monitor/port_monitor.h', ], 'dependencies': [ - '<(DEPTH)/base/base.gyp:base', 'virtual_driver_lib<(virtual_driver_suffix)', ], }, diff --git a/components/autofill/browser/data_driven_test.cc b/components/autofill/browser/data_driven_test.cc index 9d0399e..7717cf7 100644 --- a/components/autofill/browser/data_driven_test.cc +++ b/components/autofill/browser/data_driven_test.cc @@ -5,7 +5,6 @@ #include "components/autofill/browser/data_driven_test.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/path_service.h" #include "base/string_util.h" #include "chrome/common/chrome_paths.h" @@ -37,10 +36,10 @@ void DataDrivenTest::RunDataDrivenTest( const base::FilePath& input_directory, const base::FilePath& output_directory, const base::FilePath::StringType& file_name_pattern) { - base::FileEnumerator input_files(input_directory, - false, - base::FileEnumerator::FILES, - file_name_pattern); + file_util::FileEnumerator input_files(input_directory, + false, + file_util::FileEnumerator::FILES, + file_name_pattern); for (base::FilePath input_file = input_files.Next(); !input_file.empty(); diff --git a/content/browser/gpu/gpu_pixel_browsertest.cc b/content/browser/gpu/gpu_pixel_browsertest.cc index f7f2254..fb93076 100644 --- a/content/browser/gpu/gpu_pixel_browsertest.cc +++ b/content/browser/gpu/gpu_pixel_browsertest.cc @@ -4,7 +4,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/path_service.h" #include "base/string_number_conversions.h" @@ -399,10 +398,10 @@ class GpuPixelBrowserTest : public ContentBrowserTest { void ObtainLocalRefImageRevision() { base::FilePath filter; filter = filter.AppendASCII(test_name_ + "_*.rev"); - base::FileEnumerator locator(ref_img_dir_, - false, // non recursive - base::FileEnumerator::FILES, - filter.value()); + file_util::FileEnumerator locator(ref_img_dir_, + false, // non recursive + file_util::FileEnumerator::FILES, + filter.value()); int64 max_revision = 0; std::vector<base::FilePath> outdated_revs; for (base::FilePath full_path = locator.Next(); diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc index a0b945b..b95be28 100644 --- a/content/browser/indexed_db/indexed_db_context_impl.cc +++ b/content/browser/indexed_db/indexed_db_context_impl.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/message_loop_proxy.h" #include "base/string_util.h" @@ -47,8 +46,8 @@ void GetAllOriginsAndPaths( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); if (indexeddb_path.empty()) return; - base::FileEnumerator file_enumerator(indexeddb_path, - false, base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator file_enumerator(indexeddb_path, + false, file_util::FileEnumerator::DIRECTORIES); for (base::FilePath file_path = file_enumerator.Next(); !file_path.empty(); file_path = file_enumerator.Next()) { if (file_path.Extension() == IndexedDBContextImpl::kIndexedDBExtension) { diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc index 130cf08..e051d97 100644 --- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/threading/sequenced_worker_pool.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/public/browser/browser_ppapi_host.h" @@ -220,16 +219,17 @@ int32_t PepperFlashFileMessageFilter::OnGetDirContents( } ppapi::DirContents contents; - base::FileEnumerator enumerator(full_path, false, - base::FileEnumerator::FILES | - base::FileEnumerator::DIRECTORIES | - base::FileEnumerator::INCLUDE_DOT_DOT); + file_util::FileEnumerator enumerator(full_path, false, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::INCLUDE_DOT_DOT); while (!enumerator.Next().empty()) { - base::FileEnumerator::FileInfo info = enumerator.GetInfo(); + file_util::FileEnumerator::FindInfo info; + enumerator.GetFindInfo(&info); ppapi::DirEntry entry = { - info.GetName(), - info.IsDirectory() + file_util::FileEnumerator::GetFilename(info), + file_util::FileEnumerator::IsDirectory(info) }; contents.push_back(entry); } diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 9c95e32..94141d61 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/callback.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/stl_util.h" #include "base/string_number_conversions.h" @@ -183,12 +182,12 @@ const int kPartitionNameHashBytes = 6; // Needed for selecting all files in ObliterateOneDirectory() below. #if defined(OS_POSIX) -const int kAllFileTypes = base::FileEnumerator::FILES | - base::FileEnumerator::DIRECTORIES | - base::FileEnumerator::SHOW_SYM_LINKS; +const int kAllFileTypes = file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::SHOW_SYM_LINKS; #else -const int kAllFileTypes = base::FileEnumerator::FILES | - base::FileEnumerator::DIRECTORIES; +const int kAllFileTypes = file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES; #endif base::FilePath GetStoragePartitionDomainPath( @@ -209,7 +208,7 @@ void ObliterateOneDirectory(const base::FilePath& current_dir, std::vector<base::FilePath>* paths_to_consider) { CHECK(current_dir.IsAbsolute()); - base::FileEnumerator enumerator(current_dir, false, kAllFileTypes); + file_util::FileEnumerator enumerator(current_dir, false, kAllFileTypes); for (base::FilePath to_delete = enumerator.Next(); !to_delete.empty(); to_delete = enumerator.Next()) { // Enum tracking which of the 3 possible actions to take for |to_delete|. @@ -323,7 +322,7 @@ void BlockingGarbageCollect( scoped_ptr<base::hash_set<base::FilePath> > active_paths) { CHECK(storage_root.IsAbsolute()); - base::FileEnumerator enumerator(storage_root, false, kAllFileTypes); + file_util::FileEnumerator enumerator(storage_root, false, kAllFileTypes); base::FilePath trash_directory; if (!file_util::CreateTemporaryDirInDir(storage_root, kTrashDirname, &trash_directory)) { diff --git a/content/browser/zygote_host/zygote_host_impl_linux.cc b/content/browser/zygote_host/zygote_host_impl_linux.cc index c429a82..ba7884f8 100644 --- a/content/browser/zygote_host/zygote_host_impl_linux.cc +++ b/content/browser/zygote_host/zygote_host_impl_linux.cc @@ -13,7 +13,6 @@ #include "base/command_line.h" #include "base/environment.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/linux_util.h" #include "base/logging.h" #include "base/memory/linked_ptr.h" @@ -372,7 +371,8 @@ void ZygoteHostImpl::AdjustRendererOOMScore(base::ProcessHandle pid, if (!selinux_valid) { const base::FilePath kSelinuxPath("/selinux"); - base::FileEnumerator en(kSelinuxPath, false, base::FileEnumerator::FILES); + file_util::FileEnumerator en(kSelinuxPath, false, + file_util::FileEnumerator::FILES); bool has_selinux_files = !en.Next().empty(); selinux = access(kSelinuxPath.value().c_str(), X_OK) == 0 && diff --git a/content/gpu/gpu_info_collector_win.cc b/content/gpu/gpu_info_collector_win.cc index 7269883..402a4b1 100644 --- a/content/gpu/gpu_info_collector_win.cc +++ b/content/gpu/gpu_info_collector_win.cc @@ -16,7 +16,6 @@ #include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/message_loop.h" @@ -78,10 +77,10 @@ content::GpuPerformanceStats RetrieveGpuPerformanceStats() { } // Find most recent formal assessment results. - base::FileEnumerator file_enumerator( + file_util::FileEnumerator file_enumerator( base::FilePath(winsat_results_path), false, // not recursive - base::FileEnumerator::FILES, + file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("* * Formal.Assessment (*).WinSAT.xml")); base::FilePath current_results; diff --git a/content/test/image_decoder_test.cc b/content/test/image_decoder_test.cc index 4d7ffa4..b52c5c8 100644 --- a/content/test/image_decoder_test.cc +++ b/content/test/image_decoder_test.cc @@ -5,7 +5,6 @@ #include "content/test/image_decoder_test.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/md5.h" #include "base/memory/scoped_ptr.h" @@ -122,9 +121,9 @@ void ImageDecoderTest::SetUp() { std::vector<base::FilePath> ImageDecoderTest::GetImageFiles() const { std::string pattern = "*." + format_; - base::FileEnumerator enumerator(data_dir_, - false, - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(data_dir_, + false, + file_util::FileEnumerator::FILES); std::vector<base::FilePath> image_files; base::FilePath next_file_name; diff --git a/gpu/tools/compositor_model_bench/compositor_model_bench.cc b/gpu/tools/compositor_model_bench/compositor_model_bench.cc index 613ee7f..6a7c834 100644 --- a/gpu/tools/compositor_model_bench/compositor_model_bench.cc +++ b/gpu/tools/compositor_model_bench/compositor_model_bench.cc @@ -26,7 +26,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" @@ -40,6 +39,7 @@ using base::TimeTicks; using file_util::CloseFile; using file_util::DirectoryExists; +using file_util::FileEnumerator; using file_util::OpenFile; using file_util::PathExists; using std::queue; @@ -389,7 +389,7 @@ int main(int argc, char* argv[]) { if (DirectoryExists(inPath)) { LOG(INFO) << "(input path is a directory)"; - base::FileEnumerator dirItr(inPath, true, base::FileEnumerator::FILES); + FileEnumerator dirItr(inPath, true, FileEnumerator::FILES); for (base::FilePath f = dirItr.Next(); !f.empty(); f = dirItr.Next()) { sim.QueueTest(f); } diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc index 6c9047e..cf53ce0 100644 --- a/media/video/capture/linux/video_capture_device_linux.cc +++ b/media/video/capture/linux/video_capture_device_linux.cc @@ -19,7 +19,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/stringprintf.h" namespace media { @@ -101,14 +100,15 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) { device_names->clear(); base::FilePath path("/dev/"); - base::FileEnumerator enumerator( - path, false, base::FileEnumerator::FILES, "video*"); + file_util::FileEnumerator enumerator( + path, false, file_util::FileEnumerator::FILES, "video*"); while (!enumerator.Next().empty()) { - base::FileEnumerator::FileInfo info = enumerator.GetInfo(); + file_util::FileEnumerator::FindInfo info; + enumerator.GetFindInfo(&info); Name name; - name.unique_id = path.value() + info.GetName().value(); + name.unique_id = path.value() + info.filename; if ((fd = open(name.unique_id.c_str() , O_RDONLY)) < 0) { // Failed to open this device. continue; @@ -123,7 +123,7 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) { name.device_name = base::StringPrintf("%s", cap.card); device_names->push_back(name); } else { - DVLOG(1) << "No usable formats reported by " << info.GetName().value(); + DVLOG(1) << "No usable formats reported by " << info.filename; } } close(fd); diff --git a/net/base/directory_lister.cc b/net/base/directory_lister.cc index 2f7e473..c01289e 100644 --- a/net/base/directory_lister.cc +++ b/net/base/directory_lister.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/i18n/file_util_icu.h" #include "base/message_loop.h" #include "base/threading/thread_restrictions.h" @@ -32,35 +31,47 @@ bool IsDotDot(const base::FilePath& path) { bool CompareAlphaDirsFirst(const DirectoryLister::DirectoryListerData& a, const DirectoryLister::DirectoryListerData& b) { // Parent directory before all else. - if (IsDotDot(a.info.GetName())) + if (IsDotDot(file_util::FileEnumerator::GetFilename(a.info))) return true; - if (IsDotDot(b.info.GetName())) + if (IsDotDot(file_util::FileEnumerator::GetFilename(b.info))) return false; // Directories before regular files. - bool a_is_directory = a.info.IsDirectory(); - bool b_is_directory = b.info.IsDirectory(); + bool a_is_directory = file_util::FileEnumerator::IsDirectory(a.info); + bool b_is_directory = file_util::FileEnumerator::IsDirectory(b.info); if (a_is_directory != b_is_directory) return a_is_directory; - return file_util::LocaleAwareCompareFilenames(a.info.GetName(), - b.info.GetName()); + return file_util::LocaleAwareCompareFilenames( + file_util::FileEnumerator::GetFilename(a.info), + file_util::FileEnumerator::GetFilename(b.info)); } bool CompareDate(const DirectoryLister::DirectoryListerData& a, const DirectoryLister::DirectoryListerData& b) { // Parent directory before all else. - if (IsDotDot(a.info.GetName())) + if (IsDotDot(file_util::FileEnumerator::GetFilename(a.info))) return true; - if (IsDotDot(b.info.GetName())) + if (IsDotDot(file_util::FileEnumerator::GetFilename(b.info))) return false; // Directories before regular files. - bool a_is_directory = a.info.IsDirectory(); - bool b_is_directory = b.info.IsDirectory(); + bool a_is_directory = file_util::FileEnumerator::IsDirectory(a.info); + bool b_is_directory = file_util::FileEnumerator::IsDirectory(b.info); if (a_is_directory != b_is_directory) return a_is_directory; - return a.info.GetLastModifiedTime() > b.info.GetLastModifiedTime(); +#if defined(OS_POSIX) + return a.info.stat.st_mtime > b.info.stat.st_mtime; +#elif defined(OS_WIN) + if (a.info.ftLastWriteTime.dwHighDateTime == + b.info.ftLastWriteTime.dwHighDateTime) { + return a.info.ftLastWriteTime.dwLowDateTime > + b.info.ftLastWriteTime.dwLowDateTime; + } else { + return a.info.ftLastWriteTime.dwHighDateTime > + b.info.ftLastWriteTime.dwHighDateTime; + } +#endif } // Comparator for sorting find result by paths. This uses the locale-aware @@ -150,17 +161,18 @@ void DirectoryLister::Core::StartInternal() { return; } - int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES; + int types = file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES; if (!recursive_) - types |= base::FileEnumerator::INCLUDE_DOT_DOT; + types |= file_util::FileEnumerator::INCLUDE_DOT_DOT; - base::FileEnumerator file_enum(dir_, recursive_, types); + file_util::FileEnumerator file_enum(dir_, recursive_, types); base::FilePath path; std::vector<DirectoryListerData> file_data; while (lister_ && !(path = file_enum.Next()).empty()) { DirectoryListerData data; - data.info = file_enum.GetInfo(); + file_enum.GetFindInfo(&data.info); data.path = path; file_data.push_back(data); diff --git a/net/base/directory_lister.h b/net/base/directory_lister.h index e8de0ab..999b857 100644 --- a/net/base/directory_lister.h +++ b/net/base/directory_lister.h @@ -7,7 +7,7 @@ #include <vector> -#include "base/files/file_enumerator.h" +#include "base/file_util.h" #include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/message_loop_proxy.h" @@ -26,7 +26,7 @@ class NET_EXPORT DirectoryLister { public: // Represents one file found. struct DirectoryListerData { - base::FileEnumerator::FileInfo info; + file_util::FileEnumerator::FindInfo info; base::FilePath path; }; diff --git a/net/base/directory_lister_unittest.cc b/net/base/directory_lister_unittest.cc index bc4cb3a..b088c8e 100644 --- a/net/base/directory_lister_unittest.cc +++ b/net/base/directory_lister_unittest.cc @@ -5,7 +5,6 @@ #include <list> #include <utility> -#include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/i18n/file_util_icu.h" @@ -64,17 +63,18 @@ class ListerDelegate : public DirectoryLister::DirectoryListerDelegate { current < file_list_.size(); previous++, current++) { // Directories should come before files. - if (file_list_[previous].IsDirectory() && - !file_list_[current].IsDirectory()) { + if (file_util::FileEnumerator::IsDirectory(file_list_[previous]) && + !file_util::FileEnumerator::IsDirectory(file_list_[current])) { continue; } EXPECT_NE(FILE_PATH_LITERAL(".."), - file_list_[current].GetName().BaseName().value()); - EXPECT_EQ(file_list_[previous].IsDirectory(), - file_list_[current].IsDirectory()); + file_util::FileEnumerator::GetFilename( + file_list_[current]).BaseName().value()); + EXPECT_EQ(file_util::FileEnumerator::IsDirectory(file_list_[previous]), + file_util::FileEnumerator::IsDirectory(file_list_[current])); EXPECT_TRUE(file_util::LocaleAwareCompareFilenames( - file_list_[previous].GetName(), - file_list_[current].GetName())); + file_util::FileEnumerator::GetFilename(file_list_[previous]), + file_util::FileEnumerator::GetFilename(file_list_[current]))); } } } @@ -87,7 +87,7 @@ class ListerDelegate : public DirectoryLister::DirectoryListerDelegate { int error_; bool recursive_; bool quit_loop_after_each_file_; - std::vector<base::FileEnumerator::FileInfo> file_list_; + std::vector<file_util::FileEnumerator::FindInfo> file_list_; std::vector<base::FilePath> paths_; }; diff --git a/net/disk_cache/block_files_unittest.cc b/net/disk_cache/block_files_unittest.cc index fa7c5db..781c69b 100644 --- a/net/disk_cache/block_files_unittest.cc +++ b/net/disk_cache/block_files_unittest.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "net/disk_cache/block_files.h" #include "net/disk_cache/disk_cache.h" #include "net/disk_cache/disk_cache_test_base.h" @@ -16,7 +15,7 @@ namespace { // Returns the number of files in this folder. int NumberOfFiles(const base::FilePath& path) { - base::FileEnumerator iter(path, false, base::FileEnumerator::FILES); + file_util::FileEnumerator iter(path, false, file_util::FileEnumerator::FILES); int count = 0; for (base::FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) { diff --git a/net/disk_cache/cache_util_posix.cc b/net/disk_cache/cache_util_posix.cc index ffd8107..3cc9f3b 100644 --- a/net/disk_cache/cache_util_posix.cc +++ b/net/disk_cache/cache_util_posix.cc @@ -5,7 +5,6 @@ #include "net/disk_cache/cache_util.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/string_util.h" @@ -23,8 +22,9 @@ bool MoveCache(const base::FilePath& from_path, const base::FilePath& to_path) { LOG(ERROR) << "Unable to create destination cache directory."; return false; } - base::FileEnumerator iter(from_path, false /* not recursive */, - base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); + file_util::FileEnumerator iter(from_path, false /* not recursive */, + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::FILES); for (base::FilePath name = iter.Next(); !name.value().empty(); name = iter.Next()) { base::FilePath destination = to_path.Append(name.BaseName()); @@ -40,9 +40,9 @@ bool MoveCache(const base::FilePath& from_path, const base::FilePath& to_path) { } void DeleteCache(const base::FilePath& path, bool remove_folder) { - base::FileEnumerator iter(path, - /* recursive */ false, - base::FileEnumerator::FILES); + file_util::FileEnumerator iter(path, + /* recursive */ false, + file_util::FileEnumerator::FILES); for (base::FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) { if (!file_util::Delete(file, /* recursive */ false)) { diff --git a/net/disk_cache/simple/simple_index.cc b/net/disk_cache/simple/simple_index.cc index eb56a63..7effb1b 100644 --- a/net/disk_cache/simple/simple_index.cc +++ b/net/disk_cache/simple/simple_index.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" @@ -448,6 +447,7 @@ void SimpleIndex::InitializeInternal( // static scoped_ptr<SimpleIndex::EntrySet> SimpleIndex::RestoreFromDisk( const base::FilePath& index_filename) { + using file_util::FileEnumerator; LOG(INFO) << "Simple Cache Index is being restored from disk."; file_util::Delete(index_filename, /* recursive = */ false); @@ -459,10 +459,10 @@ scoped_ptr<SimpleIndex::EntrySet> SimpleIndex::RestoreFromDisk( const int kFileSuffixLenght = std::string("_0").size(); const base::FilePath::StringType file_pattern = FILE_PATH_LITERAL("*_[0-2]"); - base::FileEnumerator enumerator(index_filename.DirName(), - false /* recursive */, - base::FileEnumerator::FILES, - file_pattern); + FileEnumerator enumerator(index_filename.DirName(), + false /* recursive */, + FileEnumerator::FILES, + file_pattern); for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); file_path = enumerator.Next()) { const base::FilePath::StringType base_name = file_path.BaseName().value(); @@ -480,17 +480,18 @@ scoped_ptr<SimpleIndex::EntrySet> SimpleIndex::RestoreFromDisk( continue; } - base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); + FileEnumerator::FindInfo find_info = {}; + enumerator.GetFindInfo(&find_info); base::Time last_used_time; #if defined(OS_POSIX) // For POSIX systems, a last access time is available. However, it's not // guaranteed to be more accurate than mtime. It is no worse though. - last_used_time = base::Time::FromTimeT(find_info.stat().st_atime); + last_used_time = base::Time::FromTimeT(find_info.stat.st_atime); #endif if (last_used_time.is_null()) - last_used_time = find_info.GetLastModifiedTime(); + last_used_time = FileEnumerator::GetLastModifiedTime(find_info); - int64 file_size = find_info.GetSize(); + int64 file_size = FileEnumerator::GetFilesize(find_info); EntrySet::iterator it = index_file_entries->find(hash_key); if (it == index_file_entries->end()) { InsertInEntrySet(EntryMetadata(hash_key, last_used_time, file_size), diff --git a/net/tools/dump_cache/dump_files.cc b/net/tools/dump_cache/dump_files.cc index 061634bc..b43ca04 100644 --- a/net/tools/dump_cache/dump_files.cc +++ b/net/tools/dump_cache/dump_files.cc @@ -14,7 +14,6 @@ #include <string> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/format_macros.h" #include "base/message_loop.h" #include "net/base/file_stream.h" @@ -340,9 +339,9 @@ int DumpHeaders(const base::FilePath& input_path) { disk_cache::CacheAddr stats_addr = 0; DumpIndexHeader(index_name, &stats_addr); - base::FileEnumerator iter(input_path, false, - base::FileEnumerator::FILES, - FILE_PATH_LITERAL("data_*")); + file_util::FileEnumerator iter(input_path, false, + file_util::FileEnumerator::FILES, + FILE_PATH_LITERAL("data_*")); for (base::FilePath file = iter.Next(); !file.empty(); file = iter.Next()) DumpBlockHeader(file); diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc index 7a1906b..9d086e2 100644 --- a/net/tools/quic/quic_in_memory_cache.cc +++ b/net/tools/quic/quic_in_memory_cache.cc @@ -5,11 +5,11 @@ #include "net/tools/quic/quic_in_memory_cache.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/stl_util.h" using base::FilePath; using base::StringPiece; +using file_util::FileEnumerator; using std::string; // Specifies the directory used during QuicInMemoryCache @@ -119,9 +119,9 @@ QuicInMemoryCache::QuicInMemoryCache() { << FLAGS_quic_in_memory_cache_dir; FilePath directory(FLAGS_quic_in_memory_cache_dir); - base::FileEnumerator file_list(directory, - true, - base::FileEnumerator::FILES); + FileEnumerator file_list(directory, + true, + FileEnumerator::FILES); FilePath file = file_list.Next(); while (!file.empty()) { diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc index 7add3a0..421c62a 100644 --- a/net/url_request/url_request_file_dir_job.cc +++ b/net/url_request/url_request_file_dir_job.cc @@ -116,17 +116,27 @@ void URLRequestFileDirJob::OnListFile( } #if defined(OS_WIN) - std::string raw_bytes; // Empty on Windows means UTF-8 encoded name. + int64 size = (static_cast<unsigned __int64>(data.info.nFileSizeHigh) << 32) | + data.info.nFileSizeLow; + + // Note that we should not convert ftLastWriteTime to the local time because + // ICU's datetime formatting APIs expect time in UTC and take into account + // the timezone before formatting. + data_.append(GetDirectoryListingEntry( + data.info.cFileName, + std::string(), + ((data.info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0), + size, + base::Time::FromFileTime(data.info.ftLastWriteTime))); #elif defined(OS_POSIX) // TOOD(jungshik): The same issue as for the directory name. - const std::string& raw_bytes = data.info.GetName().value(); -#endif data_.append(GetDirectoryListingEntry( - data.info.GetName().LossyDisplayName(), - raw_bytes, - data.info.IsDirectory(), - data.info.GetSize(), - data.info.GetLastModifiedTime())); + WideToUTF16(base::SysNativeMBToWide(data.info.filename)), + data.info.filename, + S_ISDIR(data.info.stat.st_mode), + data.info.stat.st_size, + base::Time::FromTimeT(data.info.stat.st_mtime))); +#endif // TODO(darin): coalesce more? CompleteRead(); diff --git a/remoting/host/policy_hack/policy_watcher_linux.cc b/remoting/host/policy_hack/policy_watcher_linux.cc index cb63ef0..641af9c 100644 --- a/remoting/host/policy_hack/policy_watcher_linux.cc +++ b/remoting/host/policy_hack/policy_watcher_linux.cc @@ -17,7 +17,6 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/file_path_watcher.h" #include "base/json/json_file_value_serializer.h" @@ -111,9 +110,9 @@ class PolicyWatcherLinux : public PolicyWatcher { } // Enumerate the files and find the most recent modification timestamp. - base::FileEnumerator file_enumerator(config_dir_, - false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator(config_dir_, + false, + file_util::FileEnumerator::FILES); for (base::FilePath config_file = file_enumerator.Next(); !config_file.empty(); config_file = file_enumerator.Next()) { @@ -132,8 +131,8 @@ class PolicyWatcherLinux : public PolicyWatcher { DCHECK(OnPolicyWatcherThread()); // Enumerate the files and sort them lexicographically. std::set<base::FilePath> files; - base::FileEnumerator file_enumerator(config_dir_, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator(config_dir_, false, + file_util::FileEnumerator::FILES); for (base::FilePath config_file_path = file_enumerator.Next(); !config_file_path.empty(); config_file_path = file_enumerator.Next()) files.insert(config_file_path); diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index 2607dbe..a512e31 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -10,7 +10,6 @@ #include "base/at_exit.h" #include "base/debug/trace_event.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/memory/ref_counted.h" @@ -455,8 +454,8 @@ class ChromiumEnv : public Env, public UMALogger { virtual Status GetChildren(const std::string& dir, std::vector<std::string>* result) { result->clear(); - base::FileEnumerator iter( - CreateFilePath(dir), false, base::FileEnumerator::FILES); + ::file_util::FileEnumerator iter( + CreateFilePath(dir), false, ::file_util::FileEnumerator::FILES); base::FilePath current = iter.Next(); while (!current.empty()) { result->push_back(FilePathToString(current.BaseName())); diff --git a/third_party/zlib/google/zip.cc b/third_party/zlib/google/zip.cc index 2e46bed..e24449b 100644 --- a/third_party/zlib/google/zip.cc +++ b/third_party/zlib/google/zip.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/string16.h" #include "base/string_util.h" @@ -138,8 +137,9 @@ bool ZipWithFilterCallback(const base::FilePath& src_dir, } bool success = true; - base::FileEnumerator file_enumerator(src_dir, true /* recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator file_enumerator(src_dir, true /* recursive */, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { if (!filter_cb.Run(path)) { diff --git a/third_party/zlib/google/zip_unittest.cc b/third_party/zlib/google/zip_unittest.cc index e5d800b..3f7911e 100644 --- a/third_party/zlib/google/zip_unittest.cc +++ b/third_party/zlib/google/zip_unittest.cc @@ -6,7 +6,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" @@ -74,8 +73,9 @@ class ZipTest : public PlatformTest { ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); ASSERT_TRUE(zip::Unzip(path, test_dir_)); - base::FileEnumerator files(test_dir_, true, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator files(test_dir_, true, + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES); base::FilePath next_path = files.Next(); size_t count = 0; while (!next_path.value().empty()) { diff --git a/tools/android/md5sum/md5sum.cc b/tools/android/md5sum/md5sum.cc index 8543fb6..ceee7d5 100644 --- a/tools/android/md5sum/md5sum.cc +++ b/tools/android/md5sum/md5sum.cc @@ -11,7 +11,6 @@ #include <string> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/md5.h" @@ -54,8 +53,8 @@ std::set<std::string> MakeFileSet(const char** files) { for (const char** file = files; *file; ++file) { base::FilePath file_path(*file); if (file_util::DirectoryExists(file_path)) { - base::FileEnumerator file_enumerator( - file_path, true /* recurse */, base::FileEnumerator::FILES); + file_util::FileEnumerator file_enumerator( + file_path, true /* recurse */, file_util::FileEnumerator::FILES); for (base::FilePath child, empty; (child = file_enumerator.Next()) != empty; ) { // If the path contains /.svn/, ignore it. diff --git a/tools/heapcheck/suppressions.txt b/tools/heapcheck/suppressions.txt index 5f3de13..d9320f8 100644 --- a/tools/heapcheck/suppressions.txt +++ b/tools/heapcheck/suppressions.txt @@ -595,8 +595,8 @@ fun:std::string::_S_construct_aux fun:std::string::_S_construct fun:*basic_string* - fun:base::FileEnumerator::ReadDirectory - fun:base::FileEnumerator::Next + fun:file_util::FileEnumerator::ReadDirectory + fun:file_util::FileEnumerator::Next fun:::RelayReadDirectory::RunWork fun:::MessageLoopRelay::ProcessOnTargetThread } @@ -1859,4 +1859,4 @@ fun:net::URLRequest::StartJob fun:net::URLRequest::BeforeRequestComplete fun:net::URLRequest::Start -} +}
\ No newline at end of file diff --git a/tools/valgrind/tsan/suppressions.txt b/tools/valgrind/tsan/suppressions.txt index 5d57017..9d20cef 100644 --- a/tools/valgrind/tsan/suppressions.txt +++ b/tools/valgrind/tsan/suppressions.txt @@ -901,8 +901,8 @@ ThreadSanitizer:Race fun:__alloc_dir fun:opendir - fun:base::FileEnumerator::ReadDirectory - fun:base::FileEnumerator::Next + fun:file_util::FileEnumerator::ReadDirectory + fun:file_util::FileEnumerator::Next fun:::GetPrefsCandidateFilesFromFolder fun:ExternalPrefLoader::ReadStandaloneExtensionPrefFiles fun:ExternalPrefLoader::LoadOnFileThread diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc index ed217f8..85fa262 100644 --- a/webkit/database/database_tracker.cc +++ b/webkit/database/database_tracker.cc @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/message_loop_proxy.h" #include "base/platform_file.h" #include "base/strings/string_number_conversions.h" @@ -413,10 +412,10 @@ bool DatabaseTracker::DeleteOrigin(const base::string16& origin_identifier, file_util::CreateTemporaryDirInDir(db_dir_, kTemporaryDirectoryPrefix, &new_origin_dir); - base::FileEnumerator databases( + file_util::FileEnumerator databases( origin_dir, false, - base::FileEnumerator::FILES); + file_util::FileEnumerator::FILES); for (base::FilePath database = databases.Next(); !database.empty(); database = databases.Next()) { base::FilePath new_file = new_origin_dir.Append(database.BaseName()); @@ -458,10 +457,10 @@ bool DatabaseTracker::LazyInit() { // If there are left-over directories from failed deletion attempts, clean // them up. if (file_util::DirectoryExists(db_dir_)) { - base::FileEnumerator directories( + file_util::FileEnumerator directories( db_dir_, false, - base::FileEnumerator::DIRECTORIES, + file_util::FileEnumerator::DIRECTORIES, kTemporaryDirectoryPattern); for (base::FilePath directory = directories.Next(); !directory.empty(); directory = directories.Next()) { diff --git a/webkit/dom_storage/dom_storage_context.cc b/webkit/dom_storage/dom_storage_context.cc index e169e41..80df009 100644 --- a/webkit/dom_storage/dom_storage_context.cc +++ b/webkit/dom_storage/dom_storage_context.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/guid.h" #include "base/location.h" #include "base/time.h" @@ -19,6 +18,8 @@ #include "webkit/dom_storage/session_storage_database.h" #include "webkit/quota/special_storage_policy.h" +using file_util::FileEnumerator; + namespace dom_storage { static const int kSessionStoraceScavengingSeconds = 60; @@ -86,17 +87,18 @@ void DomStorageContext::GetLocalStorageUsage( bool include_file_info) { if (localstorage_directory_.empty()) return; - base::FileEnumerator enumerator(localstorage_directory_, false, - base::FileEnumerator::FILES); + FileEnumerator enumerator(localstorage_directory_, false, + FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.empty(); path = enumerator.Next()) { if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) { LocalStorageUsageInfo info; info.origin = DomStorageArea::OriginFromDatabaseFileName(path); if (include_file_info) { - base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); - info.data_size = find_info.GetSize(); - info.last_modified = find_info.GetLastModifiedTime(); + FileEnumerator::FindInfo find_info; + enumerator.GetFindInfo(&find_info); + info.data_size = FileEnumerator::GetFilesize(find_info); + info.last_modified = FileEnumerator::GetLastModifiedTime(find_info); } infos->push_back(info); } diff --git a/webkit/fileapi/file_system_database_test_helper.cc b/webkit/fileapi/file_system_database_test_helper.cc index 2c711f5..a8da1a7 100644 --- a/webkit/fileapi/file_system_database_test_helper.cc +++ b/webkit/fileapi/file_system_database_test_helper.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/stl_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/fileapi/file_system_util.h" @@ -20,8 +19,9 @@ void CorruptDatabase(const base::FilePath& db_path, leveldb::FileType type, ptrdiff_t offset, size_t size) { - base::FileEnumerator file_enum(db_path, false /* not recursive */, - base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); + file_util::FileEnumerator file_enum(db_path, false /* not recursive */, + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::FILES); base::FilePath file_path; base::FilePath picked_file_path; uint64 picked_file_number = kuint64max; @@ -81,8 +81,9 @@ void CorruptDatabase(const base::FilePath& db_path, void DeleteDatabaseFile(const base::FilePath& db_path, leveldb::FileType type) { - base::FileEnumerator file_enum(db_path, false /* not recursive */, - base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); + file_util::FileEnumerator file_enum(db_path, false /* not recursive */, + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::FILES); base::FilePath file_path; while (!(file_path = file_enum.Next()).empty()) { uint64 number = kuint64max; diff --git a/webkit/fileapi/file_system_directory_database.cc b/webkit/fileapi/file_system_directory_database.cc index 8ee3ada..95bd88f 100644 --- a/webkit/fileapi/file_system_directory_database.cc +++ b/webkit/fileapi/file_system_directory_database.cc @@ -10,7 +10,6 @@ #include <stack> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/location.h" #include "base/metrics/histogram.h" #include "base/pickle.h" @@ -282,13 +281,17 @@ bool DatabaseCheckHelper::ScanDirectory() { base::FilePath dir_path = pending_directories.top(); pending_directories.pop(); - base::FileEnumerator file_enum( + file_util::FileEnumerator file_enum( dir_path.empty() ? path_ : path_.Append(dir_path), false /* not recursive */, - base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); + file_util::FileEnumerator::DIRECTORIES | + file_util::FileEnumerator::FILES); base::FilePath absolute_file_path; while (!(absolute_file_path = file_enum.Next()).empty()) { + file_util::FileEnumerator::FindInfo find_info; + file_enum.GetFindInfo(&find_info); + base::FilePath relative_file_path; if (!path_.AppendRelativePath(absolute_file_path, &relative_file_path)) return false; @@ -297,7 +300,7 @@ bool DatabaseCheckHelper::ScanDirectory() { relative_file_path) != kExcludes + arraysize(kExcludes)) continue; - if (file_enum.GetInfo().IsDirectory()) { + if (file_util::FileEnumerator::IsDirectory(find_info)) { pending_directories.push(relative_file_path); continue; } diff --git a/webkit/fileapi/file_system_origin_database.cc b/webkit/fileapi/file_system_origin_database.cc index 5a1caea..6853587 100644 --- a/webkit/fileapi/file_system_origin_database.cc +++ b/webkit/fileapi/file_system_origin_database.cc @@ -7,7 +7,6 @@ #include <set> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/format_macros.h" #include "base/location.h" #include "base/logging.h" @@ -134,9 +133,9 @@ bool FileSystemOriginDatabase::RepairDatabase(const std::string& db_path) { // See if the repaired entries match with what we have on disk. std::set<base::FilePath> directories; - base::FileEnumerator file_enum(file_system_directory_, - false /* recursive */, - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator file_enum(file_system_directory_, + false /* recursive */, + file_util::FileEnumerator::DIRECTORIES); base::FilePath path_each; while (!(path_each = file_enum.Next()).empty()) directories.insert(path_each.BaseName()); diff --git a/webkit/fileapi/isolated_file_util_unittest.cc b/webkit/fileapi/isolated_file_util_unittest.cc index 92b9f8c..7452a31 100644 --- a/webkit/fileapi/isolated_file_util_unittest.cc +++ b/webkit/fileapi/isolated_file_util_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/message_loop.h" @@ -29,6 +28,8 @@ #include "webkit/fileapi/native_file_util.h" #include "webkit/fileapi/test_file_set.h" +using file_util::FileEnumerator; + namespace fileapi { namespace { @@ -364,17 +365,18 @@ TEST_F(IsolatedFileUtilTest, ReadDirectoryTest) { EntryMap expected_entry_map; base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); - base::FileEnumerator file_enum( + FileEnumerator file_enum( dir_path, false /* not recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + FileEnumerator::FILES | FileEnumerator::DIRECTORIES); base::FilePath current; while (!(current = file_enum.Next()).empty()) { - base::FileEnumerator::FileInfo file_info = file_enum.GetInfo(); + FileEnumerator::FindInfo file_info; + file_enum.GetFindInfo(&file_info); base::FileUtilProxy::Entry entry; - entry.is_directory = file_info.IsDirectory(); + entry.is_directory = FileEnumerator::IsDirectory(file_info); entry.name = current.BaseName().value(); - entry.size = file_info.GetSize(); - entry.last_modified_time = file_info.GetLastModifiedTime(); + entry.size = FileEnumerator::GetFilesize(file_info); + entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); expected_entry_map[entry.name] = entry; #if defined(OS_POSIX) diff --git a/webkit/fileapi/local_file_util.cc b/webkit/fileapi/local_file_util.cc index 645856c..4760423 100644 --- a/webkit/fileapi/local_file_util.cc +++ b/webkit/fileapi/local_file_util.cc @@ -4,7 +4,6 @@ #include "webkit/fileapi/local_file_util.h" -#include "base/files/file_enumerator.h" #include "base/files/file_util_proxy.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_context.h" @@ -40,8 +39,8 @@ class LocalFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator { virtual bool IsDirectory() OVERRIDE; private: - base::FileEnumerator file_enum_; - base::FileEnumerator::FileInfo file_util_info_; + file_util::FileEnumerator file_enum_; + file_util::FileEnumerator::FindInfo file_util_info_; base::FilePath platform_root_path_; base::FilePath virtual_root_path_; }; @@ -53,7 +52,7 @@ base::FilePath LocalFileEnumerator::Next() { next = file_enum_.Next(); if (next.empty()) return next; - file_util_info_ = file_enum_.GetInfo(); + file_enum_.GetFindInfo(&file_util_info_); base::FilePath path; platform_root_path_.AppendRelativePath(next, &path); @@ -61,15 +60,15 @@ base::FilePath LocalFileEnumerator::Next() { } int64 LocalFileEnumerator::Size() { - return file_util_info_.GetSize(); + return file_util::FileEnumerator::GetFilesize(file_util_info_); } base::Time LocalFileEnumerator::LastModifiedTime() { - return file_util_info_.GetLastModifiedTime(); + return file_util::FileEnumerator::GetLastModifiedTime(file_util_info_); } bool LocalFileEnumerator::IsDirectory() { - return file_util_info_.IsDirectory(); + return file_util::FileEnumerator::IsDirectory(file_util_info_); } LocalFileUtil::LocalFileUtil() { @@ -152,7 +151,8 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> LocalFileUtil:: } return make_scoped_ptr(new LocalFileEnumerator( file_path, root_url.path(), - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES)) + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES)) .PassAs<FileSystemFileUtil::AbstractFileEnumerator>(); } diff --git a/webkit/fileapi/native_file_util.cc b/webkit/fileapi/native_file_util.cc index d9b109f..e64fa05 100644 --- a/webkit/fileapi/native_file_util.cc +++ b/webkit/fileapi/native_file_util.cc @@ -5,7 +5,6 @@ #include "webkit/fileapi/native_file_util.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/memory/scoped_ptr.h" #include "webkit/fileapi/file_system_operation_context.h" @@ -56,27 +55,27 @@ class NativeFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator { virtual bool IsDirectory() OVERRIDE; private: - base::FileEnumerator file_enum_; - base::FileEnumerator::FileInfo file_util_info_; + file_util::FileEnumerator file_enum_; + file_util::FileEnumerator::FindInfo file_util_info_; }; base::FilePath NativeFileEnumerator::Next() { base::FilePath rv = file_enum_.Next(); if (!rv.empty()) - file_util_info_ = file_enum_.GetInfo(); + file_enum_.GetFindInfo(&file_util_info_); return rv; } int64 NativeFileEnumerator::Size() { - return file_util_info_.GetSize(); + return file_util::FileEnumerator::GetFilesize(file_util_info_); } base::Time NativeFileEnumerator::LastModifiedTime() { - return file_util_info_.GetLastModifiedTime(); + return file_util::FileEnumerator::GetLastModifiedTime(file_util_info_); } bool NativeFileEnumerator::IsDirectory() { - return file_util_info_.IsDirectory(); + return file_util::FileEnumerator::IsDirectory(file_util_info_); } PlatformFileError NativeFileUtil::CreateOrOpen( @@ -164,7 +163,8 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> bool recursive) { return make_scoped_ptr(new NativeFileEnumerator( root_path, recursive, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES)) + file_util::FileEnumerator::FILES | + file_util::FileEnumerator::DIRECTORIES)) .PassAs<FileSystemFileUtil::AbstractFileEnumerator>(); } diff --git a/webkit/plugins/npapi/plugin_list_mac.mm b/webkit/plugins/npapi/plugin_list_mac.mm index 922962a..66f3296 100644 --- a/webkit/plugins/npapi/plugin_list_mac.mm +++ b/webkit/plugins/npapi/plugin_list_mac.mm @@ -7,7 +7,6 @@ #import <Foundation/Foundation.h> #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/mac/mac_util.h" #include "base/string_util.h" #include "base/strings/string_number_conversions.h" @@ -79,9 +78,9 @@ void PluginList::GetPluginDirectories(std::vector<base::FilePath>* plugin_dirs) void PluginList::GetPluginsInDir( const base::FilePath& path, std::vector<base::FilePath>* plugins) { - base::FileEnumerator enumerator(path, - false, // not recursive - base::FileEnumerator::DIRECTORIES); + file_util::FileEnumerator enumerator(path, + false, // not recursive + file_util::FileEnumerator::DIRECTORIES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { plugins->push_back(path); diff --git a/webkit/plugins/npapi/plugin_list_posix.cc b/webkit/plugins/npapi/plugin_list_posix.cc index 913abd3..43d5056 100644 --- a/webkit/plugins/npapi/plugin_list_posix.cc +++ b/webkit/plugins/npapi/plugin_list_posix.cc @@ -8,7 +8,6 @@ #include "base/cpu.h" #include "base/file_util.h" -#include "base/files/file_enumerator.h" #include "base/path_service.h" #include "base/sha1.h" #include "base/string_util.h" @@ -206,9 +205,9 @@ void PluginList::GetPluginsInDir( // Construct and stat a list of all filenames under consideration, for // later sorting by mtime. FileTimeList files; - base::FileEnumerator enumerator(dir_path, - false, // not recursive - base::FileEnumerator::FILES); + file_util::FileEnumerator enumerator(dir_path, + false, // not recursive + file_util::FileEnumerator::FILES); for (base::FilePath path = enumerator.Next(); !path.value().empty(); path = enumerator.Next()) { // Skip over Mozilla .xpt files. |