| 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 <libgen.h> | 10 #include <libgen.h> |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 // least be a 'followable' link. | 563 // least be a 'followable' link. |
| 564 if (CallLstat(file_path.value().c_str(), &st) != 0) | 564 if (CallLstat(file_path.value().c_str(), &st) != 0) |
| 565 return false; | 565 return false; |
| 566 | 566 |
| 567 if (S_ISLNK(st.st_mode)) | 567 if (S_ISLNK(st.st_mode)) |
| 568 return true; | 568 return true; |
| 569 else | 569 else |
| 570 return false; | 570 return false; |
| 571 } | 571 } |
| 572 | 572 |
| 573 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { | 573 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* info) { |
| 574 if (!info) |
| 575 return false; |
| 576 |
| 574 stat_wrapper_t file_info; | 577 stat_wrapper_t file_info; |
| 575 if (CallStat(file_path.value().c_str(), &file_info) != 0) | 578 if (CallStat(file_path.value().c_str(), &file_info) != 0) |
| 576 return false; | 579 return false; |
| 577 results->is_directory = S_ISDIR(file_info.st_mode); | 580 |
| 578 results->size = file_info.st_size; | 581 info->is_directory = S_ISDIR(file_info.st_mode); |
| 582 info->is_symbolic_link = S_ISLNK(file_info.st_mode); |
| 583 info->size = file_info.st_size; |
| 584 |
| 579 #if defined(OS_MACOSX) | 585 #if defined(OS_MACOSX) |
| 580 results->last_modified = base::Time::FromTimeSpec(file_info.st_mtimespec); | 586 info->last_modified = base::Time::FromTimeSpec(file_info.st_mtimespec); |
| 581 results->last_accessed = base::Time::FromTimeSpec(file_info.st_atimespec); | 587 info->last_accessed = base::Time::FromTimeSpec(file_info.st_atimespec); |
| 582 results->creation_time = base::Time::FromTimeSpec(file_info.st_ctimespec); | 588 info->creation_time = base::Time::FromTimeSpec(file_info.st_ctimespec); |
| 583 #elif defined(OS_ANDROID) | 589 #elif defined(OS_ANDROID) |
| 584 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); | 590 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); |
| 585 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); | 591 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); |
| 586 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); | 592 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); |
| 587 #else | 593 #else |
| 588 results->last_modified = base::Time::FromTimeSpec(file_info.st_mtim); | 594 info->last_modified = base::Time::FromTimeSpec(file_info.st_mtim); |
| 589 results->last_accessed = base::Time::FromTimeSpec(file_info.st_atim); | 595 info->last_accessed = base::Time::FromTimeSpec(file_info.st_atim); |
| 590 results->creation_time = base::Time::FromTimeSpec(file_info.st_ctim); | 596 info->creation_time = base::Time::FromTimeSpec(file_info.st_ctim); |
| 591 #endif | 597 #endif |
| 592 return true; | 598 return true; |
| 593 } | 599 } |
| 594 | 600 |
| 595 bool GetInode(const FilePath& path, ino_t* inode) { | 601 bool GetInode(const FilePath& path, ino_t* inode) { |
| 596 base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). | 602 base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). |
| 597 struct stat buffer; | 603 struct stat buffer; |
| 598 int result = stat(path.value().c_str(), &buffer); | 604 int result = stat(path.value().c_str(), &buffer); |
| 599 if (result < 0) | 605 if (result < 0) |
| 600 return false; | 606 return false; |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 result = false; | 955 result = false; |
| 950 if (HANDLE_EINTR(close(outfile)) < 0) | 956 if (HANDLE_EINTR(close(outfile)) < 0) |
| 951 result = false; | 957 result = false; |
| 952 | 958 |
| 953 return result; | 959 return result; |
| 954 } | 960 } |
| 955 #endif // !defined(OS_MACOSX) | 961 #endif // !defined(OS_MACOSX) |
| 956 | 962 |
| 957 } // namespace internal | 963 } // namespace internal |
| 958 } // namespace base | 964 } // namespace base |
| OLD | NEW |