diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util.h | 4 | ||||
-rw-r--r-- | base/file_util_posix.cc | 5 | ||||
-rw-r--r-- | base/file_util_win.cc | 7 |
3 files changed, 16 insertions, 0 deletions
diff --git a/base/file_util.h b/base/file_util.h index bf5f5bf..a6914b7 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -531,6 +531,10 @@ bool RenameFileAndResetSecurityDescriptor( const FilePath& source_file_path, const FilePath& target_file_path); +// Returns whether the file has been modified since a particular date. +bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, + const base::Time& cutoff_time); + } // namespace file_util #endif // BASE_FILE_UTIL_H_ diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index a269d3f..dc9d793 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -699,4 +699,9 @@ void MemoryMappedFile::CloseHandles() { file_ = base::kInvalidPlatformFileValue; } +bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, + const base::Time& cutoff_time) { + return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); +} + } // namespace file_util diff --git a/base/file_util_win.cc b/base/file_util_win.cc index a320aca..9722e31 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -793,4 +793,11 @@ void MemoryMappedFile::CloseHandles() { length_ = INVALID_FILE_SIZE; } +bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, + const base::Time& cutoff_time) { + long result = CompareFileTime(&find_info.ftLastWriteTime, + &cutoff_time.ToFileTime()); + return result == 1 || result == 0; +} + } // namespace file_util |