diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-23 23:28:22 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-23 23:28:22 +0000 |
commit | 507fb9aa76b09905a92f1f013b1935891e60fb2b (patch) | |
tree | 2f9794ac80a82b3f132ce40554aeff859041f203 /base/file_util.cc | |
parent | ce5e69e294c5b9c9ae21746c37719bea7f28bf1e (diff) | |
download | chromium_src-507fb9aa76b09905a92f1f013b1935891e60fb2b.zip chromium_src-507fb9aa76b09905a92f1f013b1935891e60fb2b.tar.gz chromium_src-507fb9aa76b09905a92f1f013b1935891e60fb2b.tar.bz2 |
Add a TouchFile() function that takes a FilePath argument.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3496005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.cc')
-rw-r--r-- | base/file_util.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index e618903..747232b 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -200,6 +200,28 @@ bool IsDotDot(const FilePath& path) { return FILE_PATH_LITERAL("..") == path.BaseName().value(); } +bool TouchFile(const FilePath& path, + const base::Time& last_accessed, + const base::Time& last_modified) { + base::PlatformFile file = + base::CreatePlatformFile(path, + base::PLATFORM_FILE_OPEN | + base::PLATFORM_FILE_WRITE_ATTRIBUTES, + NULL, NULL); + if (file != base::kInvalidPlatformFileValue) { + bool result = base::TouchPlatformFile(file, last_accessed, last_modified); + base::ClosePlatformFile(file); + return result; + } + + return false; +} + +bool SetLastModifiedTime(const FilePath& path, + const base::Time& last_modified) { + return TouchFile(path, last_modified, last_modified); +} + bool CloseFile(FILE* file) { if (file == NULL) return true; |