OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 728 |
729 bool FileEnumerator::IsDirectory(const FindInfo& info) { | 729 bool FileEnumerator::IsDirectory(const FindInfo& info) { |
730 return S_ISDIR(info.stat.st_mode); | 730 return S_ISDIR(info.stat.st_mode); |
731 } | 731 } |
732 | 732 |
733 // static | 733 // static |
734 FilePath FileEnumerator::GetFilename(const FindInfo& find_info) { | 734 FilePath FileEnumerator::GetFilename(const FindInfo& find_info) { |
735 return FilePath(find_info.filename); | 735 return FilePath(find_info.filename); |
736 } | 736 } |
737 | 737 |
| 738 // static |
| 739 int64 FileEnumerator::GetFilesize(const FindInfo& find_info) { |
| 740 return find_info.stat.st_size; |
| 741 } |
| 742 |
| 743 // static |
| 744 base::Time FileEnumerator::GetLastModifiedTime(const FindInfo& find_info) { |
| 745 return base::Time::FromTimeT(find_info.stat.st_mtime); |
| 746 } |
| 747 |
738 bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries, | 748 bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries, |
739 const FilePath& source, bool show_links) { | 749 const FilePath& source, bool show_links) { |
740 base::ThreadRestrictions::AssertIOAllowed(); | 750 base::ThreadRestrictions::AssertIOAllowed(); |
741 DIR* dir = opendir(source.value().c_str()); | 751 DIR* dir = opendir(source.value().c_str()); |
742 if (!dir) | 752 if (!dir) |
743 return false; | 753 return false; |
744 | 754 |
745 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD) && \ | 755 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD) && \ |
746 !defined(OS_OPENBSD) && !defined(OS_SOLARIS) && !defined(OS_ANDROID) | 756 !defined(OS_OPENBSD) && !defined(OS_SOLARIS) && !defined(OS_ANDROID) |
747 #error Port warning: depending on the definition of struct dirent, \ | 757 #error Port warning: depending on the definition of struct dirent, \ |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 if (HANDLE_EINTR(close(infile)) < 0) | 934 if (HANDLE_EINTR(close(infile)) < 0) |
925 result = false; | 935 result = false; |
926 if (HANDLE_EINTR(close(outfile)) < 0) | 936 if (HANDLE_EINTR(close(outfile)) < 0) |
927 result = false; | 937 result = false; |
928 | 938 |
929 return result; | 939 return result; |
930 } | 940 } |
931 #endif // defined(OS_MACOSX) | 941 #endif // defined(OS_MACOSX) |
932 | 942 |
933 } // namespace file_util | 943 } // namespace file_util |
OLD | NEW |