summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-22 22:15:46 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-22 22:15:46 +0000
commit0408c755c0c9b65cf199b90eb07c1ba176521ac9 (patch)
treeea20d6581ea079d5fd12540fd19f8bc59e9d5777 /base
parent67c88d8a4d99d228411860a1efc4798dd9dd0ffe (diff)
downloadchromium_src-0408c755c0c9b65cf199b90eb07c1ba176521ac9.zip
chromium_src-0408c755c0c9b65cf199b90eb07c1ba176521ac9.tar.gz
chromium_src-0408c755c0c9b65cf199b90eb07c1ba176521ac9.tar.bz2
Move ComputeDirectorySize to the base namespace.
BUG= TBR=tfarina Review URL: https://chromiumcodereview.appspot.com/16950027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util.cc32
-rw-r--r--base/file_util.h21
-rw-r--r--base/file_util_unittest.cc2
-rw-r--r--base/file_util_win.cc1
4 files changed, 33 insertions, 23 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index 8e0fbb6..049bb36 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -19,8 +19,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-using base::FileEnumerator;
-using base::FilePath;
+namespace base {
namespace {
@@ -35,9 +34,26 @@ static const int kMaxUniqueFiles = 100;
} // namespace
+bool g_bug108724_debug = false;
+
+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();
+ return running_size;
+}
+
+} // namespace base
+
+// -----------------------------------------------------------------------------
+
namespace file_util {
-bool g_bug108724_debug = false;
+using base::FileEnumerator;
+using base::FilePath;
+using base::kExtensionSeparator;
+using base::kMaxUniqueFiles;
void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix) {
FilePath::StringType& value =
@@ -270,12 +286,4 @@ int GetUniquePathNumber(
return -1;
}
-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();
- return running_size;
-}
-
-} // namespace
+} // namespace file_util
diff --git a/base/file_util.h b/base/file_util.h
index ac8649f..2bf46a9 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -37,28 +37,29 @@
#endif
namespace base {
-class Time;
-
-// Returns an absolute version of a relative path. Returns an empty path on
-// error. On POSIX, this function fails if the path does not exist. This
-// function can result in I/O so it can be slow.
-BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input);
-
-} // namespace base
-namespace file_util {
+class Time;
extern bool g_bug108724_debug;
//-----------------------------------------------------------------------------
// Functions that involve filesystem access or modification:
+// Returns an absolute version of a relative path. Returns an empty path on
+// error. On POSIX, this function fails if the path does not exist. This
+// function can result in I/O so it can be slow.
+BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input);
+
// Returns the total number of bytes used by all the files under |root_path|.
// If the path does not exist the function returns 0.
//
// This function is implemented using the FileEnumerator class so it is not
// particularly speedy in any platform.
-BASE_EXPORT int64 ComputeDirectorySize(const base::FilePath& root_path);
+BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path);
+
+} // namespace base
+
+namespace file_util {
// Deletes the given path, whether it's a file or a directory.
// If it's a directory, it's perfectly happy to delete all of the
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 4df797e..cbe8f26 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -336,7 +336,7 @@ TEST_F(FileUtilTest, FileAndDirectorySize) {
FilePath file_03 = subsubdir_path.Append(FPL("The file 03.txt"));
CreateTextFile(file_03, L"123");
- int64 computed_size = file_util::ComputeDirectorySize(temp_dir_.path());
+ int64 computed_size = base::ComputeDirectorySize(temp_dir_.path());
EXPECT_EQ(size_f1 + size_f2 + 3, computed_size);
}
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 5d5dfdf..4616038 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -28,6 +28,7 @@
#include "base/win/windows_version.h"
using base::FilePath;
+using base::g_bug108724_debug;
namespace base {