OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 if (CallStat(file_path.value().c_str(), &file_info) != 0) | 479 if (CallStat(file_path.value().c_str(), &file_info) != 0) |
480 return false; | 480 return false; |
481 results->is_directory = S_ISDIR(file_info.st_mode); | 481 results->is_directory = S_ISDIR(file_info.st_mode); |
482 results->size = file_info.st_size; | 482 results->size = file_info.st_size; |
483 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 483 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
484 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 484 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
485 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 485 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
486 return true; | 486 return true; |
487 } | 487 } |
488 | 488 |
| 489 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified) { |
| 490 struct timeval times[2]; |
| 491 times[0] = last_modified.ToTimeVal(); |
| 492 times[1] = last_modified.ToTimeVal(); |
| 493 return (utimes(file_path.value().c_str(), times) == 0); |
| 494 } |
| 495 |
489 bool GetInode(const FilePath& path, ino_t* inode) { | 496 bool GetInode(const FilePath& path, ino_t* inode) { |
490 struct stat buffer; | 497 struct stat buffer; |
491 int result = stat(path.value().c_str(), &buffer); | 498 int result = stat(path.value().c_str(), &buffer); |
492 if (result < 0) | 499 if (result < 0) |
493 return false; | 500 return false; |
494 | 501 |
495 *inode = buffer.st_ino; | 502 *inode = buffer.st_ino; |
496 return true; | 503 return true; |
497 } | 504 } |
498 | 505 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 if (HANDLE_EINTR(close(infile)) < 0) | 835 if (HANDLE_EINTR(close(infile)) < 0) |
829 result = false; | 836 result = false; |
830 if (HANDLE_EINTR(close(outfile)) < 0) | 837 if (HANDLE_EINTR(close(outfile)) < 0) |
831 result = false; | 838 result = false; |
832 | 839 |
833 return result; | 840 return result; |
834 } | 841 } |
835 #endif // defined(OS_MACOSX) | 842 #endif // defined(OS_MACOSX) |
836 | 843 |
837 } // namespace file_util | 844 } // namespace file_util |
OLD | NEW |