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

Unified Diff: base/file_util.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 | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.cc
diff --git a/base/file_util.cc b/base/file_util.cc
index e76c5c2fd9afc1958c991382e55e727bd0552726..8cdf75be1141f6351bcef8138d4ce2e50c147d70 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -11,6 +11,7 @@
#include <fstream>
+#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -18,6 +19,7 @@
#include "base/strings/string_piece.h"
#include "base/utf_string_conversions.h"
+using base::FileEnumerator;
using base::FilePath;
namespace {
@@ -165,7 +167,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().value().empty())
+ if (files.Next().empty())
return true;
return false;
}
@@ -262,30 +264,9 @@ int GetUniquePathNumber(
int64 ComputeDirectorySize(const FilePath& root_path) {
int64 running_size = 0;
FileEnumerator file_iter(root_path, true, FileEnumerator::FILES);
- 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
- }
+ while (!file_iter.Next().empty())
+ running_size += file_iter.GetInfo().GetSize();
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
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698