| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } else { | 326 } else { |
| 327 errno = ENOENT; | 327 errno = ENOENT; |
| 328 } | 328 } |
| 329 return false; | 329 return false; |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 int64_t File::LengthFromPath(const char* name) { | 333 int64_t File::LengthFromPath(const char* name) { |
| 334 struct stat st; | 334 struct stat st; |
| 335 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { | 335 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { |
| 336 // Signal an error if it's a directory. |
| 337 if (S_ISDIR(st.st_mode)) { |
| 338 errno = EISDIR; |
| 339 return -1; |
| 340 } |
| 341 // Otherwise assume the caller knows what it's doing. |
| 336 return st.st_size; | 342 return st.st_size; |
| 337 } | 343 } |
| 338 return -1; | 344 return -1; |
| 339 } | 345 } |
| 340 | 346 |
| 341 | 347 |
| 342 static int64_t TimespecToMilliseconds(const struct timespec& t) { | 348 static int64_t TimespecToMilliseconds(const struct timespec& t) { |
| 343 return static_cast<int64_t>(t.tv_sec) * 1000L + | 349 return static_cast<int64_t>(t.tv_sec) * 1000L + |
| 344 static_cast<int64_t>(t.tv_nsec) / 1000000L; | 350 static_cast<int64_t>(t.tv_nsec) / 1000000L; |
| 345 } | 351 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 return ((file_1_info.st_ino == file_2_info.st_ino) && | 505 return ((file_1_info.st_ino == file_2_info.st_ino) && |
| 500 (file_1_info.st_dev == file_2_info.st_dev)) | 506 (file_1_info.st_dev == file_2_info.st_dev)) |
| 501 ? File::kIdentical | 507 ? File::kIdentical |
| 502 : File::kDifferent; | 508 : File::kDifferent; |
| 503 } | 509 } |
| 504 | 510 |
| 505 } // namespace bin | 511 } // namespace bin |
| 506 } // namespace dart | 512 } // namespace dart |
| 507 | 513 |
| 508 #endif // defined(TARGET_OS_MACOS) | 514 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |