| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 else | 581 else |
| 582 return false; | 582 return false; |
| 583 } | 583 } |
| 584 | 584 |
| 585 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { | 585 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { |
| 586 stat_wrapper_t file_info; | 586 stat_wrapper_t file_info; |
| 587 if (CallStat(file_path.value().c_str(), &file_info) != 0) | 587 if (CallStat(file_path.value().c_str(), &file_info) != 0) |
| 588 return false; | 588 return false; |
| 589 results->is_directory = S_ISDIR(file_info.st_mode); | 589 results->is_directory = S_ISDIR(file_info.st_mode); |
| 590 results->size = file_info.st_size; | 590 results->size = file_info.st_size; |
| 591 #if defined(OS_MACOSX) |
| 592 results->last_modified = base::Time::FromTimeSpec(file_info.st_mtimespec); |
| 593 results->last_accessed = base::Time::FromTimeSpec(file_info.st_atimespec); |
| 594 results->creation_time = base::Time::FromTimeSpec(file_info.st_ctimespec); |
| 595 #elif defined(OS_ANDROID) |
| 591 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 596 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
| 592 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 597 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
| 593 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 598 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
| 599 #else |
| 600 results->last_modified = base::Time::FromTimeSpec(file_info.st_mtim); |
| 601 results->last_accessed = base::Time::FromTimeSpec(file_info.st_atim); |
| 602 results->creation_time = base::Time::FromTimeSpec(file_info.st_ctim); |
| 603 #endif |
| 594 return true; | 604 return true; |
| 595 } | 605 } |
| 596 | 606 |
| 597 bool GetInode(const FilePath& path, ino_t* inode) { | 607 bool GetInode(const FilePath& path, ino_t* inode) { |
| 598 base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). | 608 base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). |
| 599 struct stat buffer; | 609 struct stat buffer; |
| 600 int result = stat(path.value().c_str(), &buffer); | 610 int result = stat(path.value().c_str(), &buffer); |
| 601 if (result < 0) | 611 if (result < 0) |
| 602 return false; | 612 return false; |
| 603 | 613 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 kFileSystemRoot, path, kRootUid, allowed_group_ids); | 1077 kFileSystemRoot, path, kRootUid, allowed_group_ids); |
| 1068 } | 1078 } |
| 1069 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1079 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 1070 | 1080 |
| 1071 int GetMaximumPathComponentLength(const FilePath& path) { | 1081 int GetMaximumPathComponentLength(const FilePath& path) { |
| 1072 base::ThreadRestrictions::AssertIOAllowed(); | 1082 base::ThreadRestrictions::AssertIOAllowed(); |
| 1073 return pathconf(path.value().c_str(), _PC_NAME_MAX); | 1083 return pathconf(path.value().c_str(), _PC_NAME_MAX); |
| 1074 } | 1084 } |
| 1075 | 1085 |
| 1076 } // namespace file_util | 1086 } // namespace file_util |
| OLD | NEW |