| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } else { | 340 } else { |
| 341 errno = ENOENT; | 341 errno = ENOENT; |
| 342 } | 342 } |
| 343 return false; | 343 return false; |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 int64_t File::LengthFromPath(const char* name) { | 347 int64_t File::LengthFromPath(const char* name) { |
| 348 struct stat st; | 348 struct stat st; |
| 349 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { | 349 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { |
| 350 // Signal an error if it's a directory. |
| 351 if (S_ISDIR(st.st_mode)) { |
| 352 errno = EISDIR; |
| 353 return -1; |
| 354 } |
| 355 // Otherwise assume the caller knows what it's doing. |
| 350 return st.st_size; | 356 return st.st_size; |
| 351 } | 357 } |
| 352 return -1; | 358 return -1; |
| 353 } | 359 } |
| 354 | 360 |
| 355 | 361 |
| 356 void File::Stat(const char* name, int64_t* data) { | 362 void File::Stat(const char* name, int64_t* data) { |
| 357 struct stat st; | 363 struct stat st; |
| 358 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { | 364 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { |
| 359 if (S_ISREG(st.st_mode)) { | 365 if (S_ISREG(st.st_mode)) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 return ((file_1_info.st_ino == file_2_info.st_ino) && | 507 return ((file_1_info.st_ino == file_2_info.st_ino) && |
| 502 (file_1_info.st_dev == file_2_info.st_dev)) | 508 (file_1_info.st_dev == file_2_info.st_dev)) |
| 503 ? File::kIdentical | 509 ? File::kIdentical |
| 504 : File::kDifferent; | 510 : File::kDifferent; |
| 505 } | 511 } |
| 506 | 512 |
| 507 } // namespace bin | 513 } // namespace bin |
| 508 } // namespace dart | 514 } // namespace dart |
| 509 | 515 |
| 510 #endif // defined(TARGET_OS_FUCHSIA) | 516 #endif // defined(TARGET_OS_FUCHSIA) |
| OLD | NEW |