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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // 1. Get |comparison_time| by Time::Now() and the value is 10.1 (secs). | 125 // 1. Get |comparison_time| by Time::Now() and the value is 10.1 (secs). |
126 // 2. Create a file and the current time is 10.3 (secs). | 126 // 2. Create a file and the current time is 10.3 (secs). |
127 // | 127 // |
128 // As POSIX doesn't have microsecond precision for |st_ctime|, | 128 // As POSIX doesn't have microsecond precision for |st_ctime|, |
129 // the creation time of the file created in the step 2 is 10 and | 129 // the creation time of the file created in the step 2 is 10 and |
130 // the file is considered older than |comparison_time|. After | 130 // the file is considered older than |comparison_time|. After |
131 // all, we may have to accept either of the two issues: 1. files | 131 // all, we may have to accept either of the two issues: 1. files |
132 // which are older than |comparison_time| are considered newer | 132 // which are older than |comparison_time| are considered newer |
133 // (current implementation) 2. files newer than | 133 // (current implementation) 2. files newer than |
134 // |comparison_time| are considered older. | 134 // |comparison_time| are considered older. |
135 if (st.st_ctime >= comparison_time.ToTimeT()) | 135 if (static_cast<time_t>(st.st_ctime) >= comparison_time.ToTimeT()) |
136 ++file_count; | 136 ++file_count; |
137 } | 137 } |
138 closedir(dir); | 138 closedir(dir); |
139 } | 139 } |
140 return file_count; | 140 return file_count; |
141 } | 141 } |
142 | 142 |
143 // TODO(erikkay): The Windows version of this accepts paths like "foo/bar/*" | 143 // TODO(erikkay): The Windows version of this accepts paths like "foo/bar/*" |
144 // which works both with and without the recursive flag. I'm not sure we need | 144 // which works both with and without the recursive flag. I'm not sure we need |
145 // that functionality. If not, remove from file_util_win.cc, otherwise add it | 145 // that functionality. If not, remove from file_util_win.cc, otherwise add it |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 if (file_ != base::kInvalidPlatformFileValue) | 755 if (file_ != base::kInvalidPlatformFileValue) |
756 close(file_); | 756 close(file_); |
757 | 757 |
758 data_ = NULL; | 758 data_ = NULL; |
759 length_ = 0; | 759 length_ = 0; |
760 file_ = base::kInvalidPlatformFileValue; | 760 file_ = base::kInvalidPlatformFileValue; |
761 } | 761 } |
762 | 762 |
763 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, | 763 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, |
764 const base::Time& cutoff_time) { | 764 const base::Time& cutoff_time) { |
765 return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); | 765 return static_cast<time_t>(find_info.stat.st_mtime) >= cutoff_time.ToTimeT(); |
766 } | 766 } |
767 | 767 |
768 bool NormalizeFilePath(const FilePath& path, FilePath* normalized_path) { | 768 bool NormalizeFilePath(const FilePath& path, FilePath* normalized_path) { |
769 FilePath real_path_result; | 769 FilePath real_path_result; |
770 if (!RealPath(path, &real_path_result)) | 770 if (!RealPath(path, &real_path_result)) |
771 return false; | 771 return false; |
772 | 772 |
773 // To be consistant with windows, fail if |real_path_result| is a | 773 // To be consistant with windows, fail if |real_path_result| is a |
774 // directory. | 774 // directory. |
775 stat_wrapper_t file_info; | 775 stat_wrapper_t file_info; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 if (HANDLE_EINTR(close(infile)) < 0) | 858 if (HANDLE_EINTR(close(infile)) < 0) |
859 result = false; | 859 result = false; |
860 if (HANDLE_EINTR(close(outfile)) < 0) | 860 if (HANDLE_EINTR(close(outfile)) < 0) |
861 result = false; | 861 result = false; |
862 | 862 |
863 return result; | 863 return result; |
864 } | 864 } |
865 #endif // defined(OS_MACOSX) | 865 #endif // defined(OS_MACOSX) |
866 | 866 |
867 } // namespace file_util | 867 } // namespace file_util |
OLD | NEW |