summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-15 16:58:27 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-15 16:58:27 +0000
commit807b930a4890f8e86dfd770a571b49eca0c1b4a6 (patch)
tree572323f1e64a884fe4befb334cfec11e85aad2eb /base
parent55bb2b11a6c372f70445fd11e211f53944214fa7 (diff)
downloadchromium_src-807b930a4890f8e86dfd770a571b49eca0c1b4a6.zip
chromium_src-807b930a4890f8e86dfd770a571b49eca0c1b4a6.tar.gz
chromium_src-807b930a4890f8e86dfd770a571b49eca0c1b4a6.tar.bz2
Reverting 13748.
Review URL: http://codereview.chromium.org/73084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util.h11
-rw-r--r--base/file_util_unittest.cc17
-rw-r--r--base/file_util_win.cc11
3 files changed, 18 insertions, 21 deletions
diff --git a/base/file_util.h b/base/file_util.h
index 20d98b0..6c916dd 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -27,10 +27,6 @@
#include "base/scoped_ptr.h"
#include "base/file_path.h"
-namespace base {
-class Time;
-}
-
namespace file_util {
//-----------------------------------------------------------------------------
@@ -139,9 +135,10 @@ void ReplaceIllegalCharacters(std::wstring* file_name, int replace_char);
#if defined(OS_WIN)
// Returns the number of files matching the current path that were
-// created on or after the given |file_time|. Doesn't count ".." or ".".
-int CountFilesCreatedAfter(const FilePath& path,
- const base::Time& file_time);
+// created on or after the given FILETIME. Doesn't count ".." or ".".
+// Filetime is UTC filetime, not LocalFiletime.
+int CountFilesCreatedAfter(const std::wstring& path,
+ const FILETIME& file_time);
#endif // defined(OS_WIN)
// Deletes the given path, whether it's a file or a directory.
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index df30817..7f24fc5 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -20,7 +20,6 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/string_util.h"
-#include "base/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -317,26 +316,30 @@ TEST_F(FileUtilTest, GetDirectoryFromPath) {
#if defined OS_WIN
TEST_F(FileUtilTest, CountFilesCreatedAfter) {
// Create old file (that we don't want to count)
- FilePath old_file_name = test_dir_.Append(FILE_PATH_LITERAL("Old File.txt"));
+ FilePath old_file_name = test_dir_.Append(L"Old File.txt");
CreateTextFile(old_file_name, L"Just call me Mr. Creakybits");
// Age to perfection
Sleep(100);
// Establish our cutoff time
- base::Time now(base::Time::Now());
- EXPECT_EQ(0, file_util::CountFilesCreatedAfter(test_dir_, now));
+ FILETIME test_start_time;
+ GetSystemTimeAsFileTime(&test_start_time);
+ EXPECT_EQ(0, file_util::CountFilesCreatedAfter(test_dir_.value(),
+ test_start_time));
// Create a new file (that we do want to count)
- FilePath new_file_name = test_dir_.Append(FILE_PATH_LITERAL("New File.txt"));
+ FilePath new_file_name = test_dir_.Append(L"New File.txt");
CreateTextFile(new_file_name, L"Waaaaaaaaaaaaaah.");
// We should see only the new file.
- EXPECT_EQ(1, file_util::CountFilesCreatedAfter(test_dir_, now));
+ EXPECT_EQ(1, file_util::CountFilesCreatedAfter(test_dir_.value(),
+ test_start_time));
// Delete new file, we should see no files after cutoff now
EXPECT_TRUE(file_util::Delete(new_file_name, false));
- EXPECT_EQ(0, file_util::CountFilesCreatedAfter(test_dir_, now));
+ EXPECT_EQ(0, file_util::CountFilesCreatedAfter(test_dir_.value(),
+ test_start_time));
}
#endif
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 8b3d4f5..841cd28 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -14,7 +14,6 @@
#include "base/logging.h"
#include "base/scoped_handle.h"
#include "base/string_util.h"
-#include "base/time.h"
#include "base/win_util.h"
namespace file_util {
@@ -40,14 +39,12 @@ bool AbsolutePath(FilePath* path) {
return true;
}
-int CountFilesCreatedAfter(const FilePath& path,
- const base::Time& comparison_time) {
+int CountFilesCreatedAfter(const std::wstring& path,
+ const FILETIME& comparison_time) {
int file_count = 0;
- FILETIME comparison_filetime(comparison_time.ToFileTime());
WIN32_FIND_DATA find_file_data;
- // All files in given dir
- std::wstring filename_spec = path.Append(L"*").value();
+ std::wstring filename_spec = path + L"\\*"; // All files in given dir
HANDLE find_handle = FindFirstFile(filename_spec.c_str(), &find_file_data);
if (find_handle != INVALID_HANDLE_VALUE) {
do {
@@ -57,7 +54,7 @@ int CountFilesCreatedAfter(const FilePath& path,
continue;
long result = CompareFileTime(&find_file_data.ftCreationTime,
- &comparison_filetime);
+ &comparison_time);
// File was created after or on comparison time
if ((result == 1) || (result == 0))
++file_count;