Index: base/file_util_posix.cc |
=================================================================== |
--- base/file_util_posix.cc (revision 14056) |
+++ base/file_util_posix.cc (working copy) |
@@ -4,6 +4,7 @@ |
#include "base/file_util.h" |
+#include <dirent.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fnmatch.h> |
@@ -14,7 +15,9 @@ |
#include <sys/errno.h> |
#include <sys/mman.h> |
#include <sys/stat.h> |
+#include <sys/types.h> |
#include <time.h> |
+#include <unistd.h> |
#include <fstream> |
@@ -22,6 +25,7 @@ |
#include "base/file_path.h" |
#include "base/logging.h" |
#include "base/string_util.h" |
+#include "base/time.h" |
namespace file_util { |
@@ -51,6 +55,32 @@ |
return true; |
} |
+int CountFilesCreatedAfter(const FilePath& path, |
+ const base::Time& comparison_time) { |
+ int file_count = 0; |
+ |
+ DIR* dir = opendir(path.value().c_str()); |
+ if (dir) { |
+ struct dirent* ent; |
+ while ((ent = readdir(dir)) != NULL) { |
Erik does not do reviews
2009/04/21 16:10:21
lint says to use readdir_r instead of readdir (see
|
+ if ((strcmp(ent->d_name, ".") == 0) || |
+ (strcmp(ent->d_name, "..") == 0)) |
+ continue; |
+ |
+ struct stat64 st; |
+ int test = stat64(path.Append(ent->d_name).value().c_str(), &st); |
+ if (test != 0) { |
+ LOG(ERROR) << "stat64 failed: " << strerror(errno); |
+ continue; |
+ } |
+ if (st.st_ctime >= comparison_time.ToTimeT()) |
Hironori Bono
2009/04/22 04:46:27
nit: If I recall correctly, base::Time::ToTimeT()
hamaji
2009/04/22 05:12:23
Good point. However, if we use Time::DoubleT(), I
Hironori Bono
2009/04/22 05:35:58
I'm wondering why you did not write this comment i
|
+ ++file_count; |
+ } |
+ closedir(dir); |
+ } |
+ return file_count; |
+} |
+ |
// TODO(erikkay): The Windows version of this accepts paths like "foo/bar/*" |
// which works both with and without the recursive flag. I'm not sure we need |
// that functionality. If not, remove from file_util_win.cc, otherwise add it |