| 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(HOST_OS_ANDROID) | 6 #if defined(HOST_OS_ANDROID) |
| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (!StatHelper(namespc, name, &st)) { | 490 if (!StatHelper(namespc, name, &st)) { |
| 491 return -1; | 491 return -1; |
| 492 } | 492 } |
| 493 return st.st_atime; | 493 return st.st_atime; |
| 494 } | 494 } |
| 495 | 495 |
| 496 bool File::SetLastAccessed(Namespace* namespc, | 496 bool File::SetLastAccessed(Namespace* namespc, |
| 497 const char* name, | 497 const char* name, |
| 498 int64_t millis) { | 498 int64_t millis) { |
| 499 // First get the current times. | 499 // First get the current times. |
| 500 struct stat64 st; | 500 struct stat st; |
| 501 if (!StatHelper(namespc, name, &st)) { | 501 if (!StatHelper(namespc, name, &st)) { |
| 502 return false; | 502 return false; |
| 503 } | 503 } |
| 504 | 504 |
| 505 // Set the new time: | 505 // Set the new time: |
| 506 NamespaceScope ns(namespc, name); | 506 NamespaceScope ns(namespc, name); |
| 507 struct timespec times[2]; | 507 struct timespec times[2]; |
| 508 MillisecondsToTimespec(millis, ×[0]); | 508 MillisecondsToTimespec(millis, ×[0]); |
| 509 MillisecondsToTimespec(static_cast<int64_t>(st.st_mtime) * 1000, ×[1]); | 509 MillisecondsToTimespec(static_cast<int64_t>(st.st_mtime) * 1000, ×[1]); |
| 510 return utimensat(ns.fd(), ns.path(), times, 0) == 0; | 510 return utimensat(ns.fd(), ns.path(), times, 0) == 0; |
| 511 } | 511 } |
| 512 | 512 |
| 513 bool File::SetLastModified(Namespace* namespc, | 513 bool File::SetLastModified(Namespace* namespc, |
| 514 const char* name, | 514 const char* name, |
| 515 int64_t millis) { | 515 int64_t millis) { |
| 516 // First get the current times. | 516 // First get the current times. |
| 517 struct stat64 st; | 517 struct stat st; |
| 518 if (!StatHelper(namespc, name, &st)) { | 518 if (!StatHelper(namespc, name, &st)) { |
| 519 return false; | 519 return false; |
| 520 } | 520 } |
| 521 | 521 |
| 522 // Set the new time: | 522 // Set the new time: |
| 523 NamespaceScope ns(namespc, name); | 523 NamespaceScope ns(namespc, name); |
| 524 struct timespec times[2]; | 524 struct timespec times[2]; |
| 525 MillisecondsToTimespec(static_cast<int64_t>(st.st_atime) * 1000, ×[0]); | 525 MillisecondsToTimespec(static_cast<int64_t>(st.st_atime) * 1000, ×[0]); |
| 526 MillisecondsToTimespec(millis, ×[1]); | 526 MillisecondsToTimespec(millis, ×[1]); |
| 527 return utimensat(ns.fd(), ns.path(), times, 0) == 0; | 527 return utimensat(ns.fd(), ns.path(), times, 0) == 0; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 return ((file_1_info.st_ino == file_2_info.st_ino) && | 667 return ((file_1_info.st_ino == file_2_info.st_ino) && |
| 668 (file_1_info.st_dev == file_2_info.st_dev)) | 668 (file_1_info.st_dev == file_2_info.st_dev)) |
| 669 ? File::kIdentical | 669 ? File::kIdentical |
| 670 : File::kDifferent; | 670 : File::kDifferent; |
| 671 } | 671 } |
| 672 | 672 |
| 673 } // namespace bin | 673 } // namespace bin |
| 674 } // namespace dart | 674 } // namespace dart |
| 675 | 675 |
| 676 #endif // defined(HOST_OS_ANDROID) | 676 #endif // defined(HOST_OS_ANDROID) |
| OLD | NEW |