| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } else { | 368 } else { |
| 369 errno = ENOENT; | 369 errno = ENOENT; |
| 370 } | 370 } |
| 371 return false; | 371 return false; |
| 372 } | 372 } |
| 373 | 373 |
| 374 | 374 |
| 375 int64_t File::LengthFromPath(const char* name) { | 375 int64_t File::LengthFromPath(const char* name) { |
| 376 struct stat64 st; | 376 struct stat64 st; |
| 377 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { | 377 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { |
| 378 // Signal an error if it's a directory. |
| 379 if (S_ISDIR(st.st_mode)) { |
| 380 errno = EISDIR; |
| 381 return -1; |
| 382 } |
| 383 // Otherwise assume the caller knows what it's doing. |
| 378 return st.st_size; | 384 return st.st_size; |
| 379 } | 385 } |
| 380 return -1; | 386 return -1; |
| 381 } | 387 } |
| 382 | 388 |
| 383 | 389 |
| 384 static int64_t TimespecToMilliseconds(const struct timespec& t) { | 390 static int64_t TimespecToMilliseconds(const struct timespec& t) { |
| 385 return static_cast<int64_t>(t.tv_sec) * 1000L + | 391 return static_cast<int64_t>(t.tv_sec) * 1000L + |
| 386 static_cast<int64_t>(t.tv_nsec) / 1000000L; | 392 static_cast<int64_t>(t.tv_nsec) / 1000000L; |
| 387 } | 393 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 return ((file_1_info.st_ino == file_2_info.st_ino) && | 542 return ((file_1_info.st_ino == file_2_info.st_ino) && |
| 537 (file_1_info.st_dev == file_2_info.st_dev)) | 543 (file_1_info.st_dev == file_2_info.st_dev)) |
| 538 ? File::kIdentical | 544 ? File::kIdentical |
| 539 : File::kDifferent; | 545 : File::kDifferent; |
| 540 } | 546 } |
| 541 | 547 |
| 542 } // namespace bin | 548 } // namespace bin |
| 543 } // namespace dart | 549 } // namespace dart |
| 544 | 550 |
| 545 #endif // defined(TARGET_OS_LINUX) | 551 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |