OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
7 | 7 |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 off_t File::LengthFromPath(const char* name) { | 198 off_t File::LengthFromPath(const char* name) { |
199 struct stat st; | 199 struct stat st; |
200 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 200 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
201 return st.st_size; | 201 return st.st_size; |
202 } | 202 } |
203 return -1; | 203 return -1; |
204 } | 204 } |
205 | 205 |
206 | 206 |
| 207 void File::Stat(const char* name, int64_t* data) { |
| 208 struct stat st; |
| 209 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
| 210 if (S_ISREG(st.st_mode)) { |
| 211 data[kType] = kIsFile; |
| 212 } else if (S_ISDIR(st.st_mode)) { |
| 213 data[kType] = kIsDirectory; |
| 214 } else if (S_ISLNK(st.st_mode)) { |
| 215 data[kType] = kIsLink; |
| 216 } else { |
| 217 data[kType] = kDoesNotExist; |
| 218 } |
| 219 data[kCreatedTime] = st.st_ctime; |
| 220 data[kModifiedTime] = st.st_mtime; |
| 221 data[kAccessedTime] = st.st_atime; |
| 222 data[kMode] = st.st_mode; |
| 223 data[kSize] = st.st_size; |
| 224 } else { |
| 225 data[kType] = kDoesNotExist; |
| 226 data[kCreatedTime] = 0; |
| 227 data[kModifiedTime] = 0; |
| 228 data[kAccessedTime] = 0; |
| 229 data[kMode] = 0; |
| 230 data[kSize] = 0; |
| 231 } |
| 232 } |
| 233 |
| 234 |
207 time_t File::LastModified(const char* name) { | 235 time_t File::LastModified(const char* name) { |
208 struct stat st; | 236 struct stat st; |
209 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 237 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
210 return st.st_mtime; | 238 return st.st_mtime; |
211 } | 239 } |
212 return -1; | 240 return -1; |
213 } | 241 } |
214 | 242 |
215 | 243 |
216 char* File::LinkTarget(const char* pathname) { | 244 char* File::LinkTarget(const char* pathname) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 return (file_1_info.st_ino == file_2_info.st_ino && | 353 return (file_1_info.st_ino == file_2_info.st_ino && |
326 file_1_info.st_dev == file_2_info.st_dev) ? | 354 file_1_info.st_dev == file_2_info.st_dev) ? |
327 File::kIdentical : | 355 File::kIdentical : |
328 File::kDifferent; | 356 File::kDifferent; |
329 } | 357 } |
330 | 358 |
331 } // namespace bin | 359 } // namespace bin |
332 } // namespace dart | 360 } // namespace dart |
333 | 361 |
334 #endif // defined(TARGET_OS_MACOS) | 362 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |