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 <copyfile.h> // NOLINT | 10 #include <copyfile.h> // NOLINT |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 data[kSize] = st.st_size; | 373 data[kSize] = st.st_size; |
374 } else { | 374 } else { |
375 data[kType] = kDoesNotExist; | 375 data[kType] = kDoesNotExist; |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 | 379 |
380 time_t File::LastModified(const char* name) { | 380 time_t File::LastModified(const char* name) { |
381 struct stat st; | 381 struct stat st; |
382 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { | 382 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { |
| 383 // Signal an error if it's a directory. |
| 384 if (S_ISDIR(st.st_mode)) { |
| 385 errno = EISDIR; |
| 386 return -1; |
| 387 } |
| 388 // Otherwise assume the caller knows what it's doing. |
383 return st.st_mtime; | 389 return st.st_mtime; |
384 } | 390 } |
385 return -1; | 391 return -1; |
386 } | 392 } |
387 | 393 |
388 | 394 |
389 const char* File::LinkTarget(const char* pathname) { | 395 const char* File::LinkTarget(const char* pathname) { |
390 struct stat link_stats; | 396 struct stat link_stats; |
391 if (lstat(pathname, &link_stats) != 0) { | 397 if (lstat(pathname, &link_stats) != 0) { |
392 return NULL; | 398 return NULL; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 return ((file_1_info.st_ino == file_2_info.st_ino) && | 511 return ((file_1_info.st_ino == file_2_info.st_ino) && |
506 (file_1_info.st_dev == file_2_info.st_dev)) | 512 (file_1_info.st_dev == file_2_info.st_dev)) |
507 ? File::kIdentical | 513 ? File::kIdentical |
508 : File::kDifferent; | 514 : File::kDifferent; |
509 } | 515 } |
510 | 516 |
511 } // namespace bin | 517 } // namespace bin |
512 } // namespace dart | 518 } // namespace dart |
513 | 519 |
514 #endif // defined(TARGET_OS_MACOS) | 520 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |