Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: net/base/directory_lister.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/directory_lister.h ('k') | net/base/directory_lister_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/directory_lister.cc
diff --git a/net/base/directory_lister.cc b/net/base/directory_lister.cc
index c01289e546892f52e77356e8bde80498e3640ad9..2f7e473d17b9c344864bd3378d56fbea2e6546ee 100644
--- a/net/base/directory_lister.cc
+++ b/net/base/directory_lister.cc
@@ -9,6 +9,7 @@
#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"
@@ -31,47 +32,35 @@ bool IsDotDot(const base::FilePath& path) {
bool CompareAlphaDirsFirst(const DirectoryLister::DirectoryListerData& a,
const DirectoryLister::DirectoryListerData& b) {
// Parent directory before all else.
- if (IsDotDot(file_util::FileEnumerator::GetFilename(a.info)))
+ if (IsDotDot(a.info.GetName()))
return true;
- if (IsDotDot(file_util::FileEnumerator::GetFilename(b.info)))
+ if (IsDotDot(b.info.GetName()))
return false;
// Directories before regular files.
- bool a_is_directory = file_util::FileEnumerator::IsDirectory(a.info);
- bool b_is_directory = file_util::FileEnumerator::IsDirectory(b.info);
+ bool a_is_directory = a.info.IsDirectory();
+ bool b_is_directory = b.info.IsDirectory();
if (a_is_directory != b_is_directory)
return a_is_directory;
- return file_util::LocaleAwareCompareFilenames(
- file_util::FileEnumerator::GetFilename(a.info),
- file_util::FileEnumerator::GetFilename(b.info));
+ return file_util::LocaleAwareCompareFilenames(a.info.GetName(),
+ b.info.GetName());
}
bool CompareDate(const DirectoryLister::DirectoryListerData& a,
const DirectoryLister::DirectoryListerData& b) {
// Parent directory before all else.
- if (IsDotDot(file_util::FileEnumerator::GetFilename(a.info)))
+ if (IsDotDot(a.info.GetName()))
return true;
- if (IsDotDot(file_util::FileEnumerator::GetFilename(b.info)))
+ if (IsDotDot(b.info.GetName()))
return false;
// Directories before regular files.
- bool a_is_directory = file_util::FileEnumerator::IsDirectory(a.info);
- bool b_is_directory = file_util::FileEnumerator::IsDirectory(b.info);
+ bool a_is_directory = a.info.IsDirectory();
+ bool b_is_directory = b.info.IsDirectory();
if (a_is_directory != b_is_directory)
return a_is_directory;
-#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
+ return a.info.GetLastModifiedTime() > b.info.GetLastModifiedTime();
}
// Comparator for sorting find result by paths. This uses the locale-aware
@@ -161,18 +150,17 @@ void DirectoryLister::Core::StartInternal() {
return;
}
- int types = file_util::FileEnumerator::FILES |
- file_util::FileEnumerator::DIRECTORIES;
+ int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES;
if (!recursive_)
- types |= file_util::FileEnumerator::INCLUDE_DOT_DOT;
+ types |= base::FileEnumerator::INCLUDE_DOT_DOT;
- file_util::FileEnumerator file_enum(dir_, recursive_, types);
+ base::FileEnumerator file_enum(dir_, recursive_, types);
base::FilePath path;
std::vector<DirectoryListerData> file_data;
while (lister_ && !(path = file_enum.Next()).empty()) {
DirectoryListerData data;
- file_enum.GetFindInfo(&data.info);
+ data.info = file_enum.GetInfo();
data.path = path;
file_data.push_back(data);
« no previous file with comments | « net/base/directory_lister.h ('k') | net/base/directory_lister_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698