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 | |
496 bool GetInode(const FilePath& path, ino_t* inode) { | 489 bool GetInode(const FilePath& path, ino_t* inode) { |
497 struct stat buffer; | 490 struct stat buffer; |
498 int result = stat(path.value().c_str(), &buffer); | 491 int result = stat(path.value().c_str(), &buffer); |
499 if (result < 0) | 492 if (result < 0) |
500 return false; | 493 return false; |
501 | 494 |
502 *inode = buffer.st_ino; | 495 *inode = buffer.st_ino; |
503 return true; | 496 return true; |
504 } | 497 } |
505 | 498 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 if (HANDLE_EINTR(close(infile)) < 0) | 828 if (HANDLE_EINTR(close(infile)) < 0) |
836 result = false; | 829 result = false; |
837 if (HANDLE_EINTR(close(outfile)) < 0) | 830 if (HANDLE_EINTR(close(outfile)) < 0) |
838 result = false; | 831 result = false; |
839 | 832 |
840 return result; | 833 return result; |
841 } | 834 } |
842 #endif // defined(OS_MACOSX) | 835 #endif // defined(OS_MACOSX) |
843 | 836 |
844 } // namespace file_util | 837 } // namespace file_util |
OLD | NEW |