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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return base::StringPrintf(".%s.XXXXXX", base::mac::BaseBundleID()); | 143 return base::StringPrintf(".%s.XXXXXX", base::mac::BaseBundleID()); |
144 #endif | 144 #endif |
145 | 145 |
146 #if defined(GOOGLE_CHROME_BUILD) | 146 #if defined(GOOGLE_CHROME_BUILD) |
147 return std::string(".com.google.Chrome.XXXXXX"); | 147 return std::string(".com.google.Chrome.XXXXXX"); |
148 #else | 148 #else |
149 return std::string(".org.chromium.Chromium.XXXXXX"); | 149 return std::string(".org.chromium.Chromium.XXXXXX"); |
150 #endif | 150 #endif |
151 } | 151 } |
152 | 152 |
153 bool AbsolutePath(FilePath* path) { | |
154 base::ThreadRestrictions::AssertIOAllowed(); // For realpath(). | |
155 char full_path[PATH_MAX]; | |
156 if (realpath(path->value().c_str(), full_path) == NULL) | |
157 return false; | |
158 *path = FilePath(full_path); | |
159 return true; | |
160 } | |
161 | |
162 int CountFilesCreatedAfter(const FilePath& path, | 153 int CountFilesCreatedAfter(const FilePath& path, |
163 const base::Time& comparison_time) { | 154 const base::Time& comparison_time) { |
164 base::ThreadRestrictions::AssertIOAllowed(); | 155 base::ThreadRestrictions::AssertIOAllowed(); |
165 int file_count = 0; | 156 int file_count = 0; |
166 | 157 |
167 DIR* dir = opendir(path.value().c_str()); | 158 DIR* dir = opendir(path.value().c_str()); |
168 if (dir) { | 159 if (dir) { |
169 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_BSD) && \ | 160 #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_BSD) && \ |
170 !defined(OS_SOLARIS) && !defined(OS_ANDROID) | 161 !defined(OS_SOLARIS) && !defined(OS_ANDROID) |
171 #error Port warning: depending on the definition of struct dirent, \ | 162 #error Port warning: depending on the definition of struct dirent, \ |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 kFileSystemRoot, path, kRootUid, allowed_group_ids); | 1082 kFileSystemRoot, path, kRootUid, allowed_group_ids); |
1092 } | 1083 } |
1093 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1084 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
1094 | 1085 |
1095 int GetMaximumPathComponentLength(const FilePath& path) { | 1086 int GetMaximumPathComponentLength(const FilePath& path) { |
1096 base::ThreadRestrictions::AssertIOAllowed(); | 1087 base::ThreadRestrictions::AssertIOAllowed(); |
1097 return pathconf(path.value().c_str(), _PC_NAME_MAX); | 1088 return pathconf(path.value().c_str(), _PC_NAME_MAX); |
1098 } | 1089 } |
1099 | 1090 |
1100 } // namespace file_util | 1091 } // namespace file_util |
OLD | NEW |