diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 05:46:20 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 05:46:20 +0000 |
commit | 9e66a9b94a40eeeeb52c47c83990b0766e1b7ceb (patch) | |
tree | 0818f910c522fb5bda00cab55412201251db32f7 /base/file_util.cc | |
parent | ad5b14e00b36aab6e2b2d6aba8477a5dd9a11998 (diff) | |
download | chromium_src-9e66a9b94a40eeeeb52c47c83990b0766e1b7ceb.zip chromium_src-9e66a9b94a40eeeeb52c47c83990b0766e1b7ceb.tar.gz chromium_src-9e66a9b94a40eeeeb52c47c83990b0766e1b7ceb.tar.bz2 |
Revert 198820 "Move FileEnumerator to its own file, do some refa..."
Broke both windows clobber and official builders' compile with this error:
771>Link:
771> Creating library ..\..\..\build\Release\lib\gcp_portmon64.lib and
object ..\..\..\build\Release\lib\gcp_portmon64.exp
771>base.lib(path_service.obj) : fatalerror LNK1112: module machine type 'X86'
conflicts with target machine type 'x64'
771>
771>Build FAILED.
> Move FileEnumerator to its own file, do some refactoring.
>
> It creates a class FileInfo to contain the details rather than using a platform-specific typedef. This allows the accessors GetName, GetSize, etc. to be moved directly to this class (previously they were static helpers on the FileEnumerator class) which makes a bunch of code much cleaner. It also gives reasonable getting and initialization which the previous version lacked.
>
> BUG=175002
> R=rvargas@chromium.org
>
> Review URL: https://codereview.chromium.org/13165005
TBR=brettw@chromium.org
Review URL: https://codereview.chromium.org/14824006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.cc')
-rw-r--r-- | base/file_util.cc | 29 |
1 files changed, 24 insertions, 5 deletions
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 |