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_ANDROID) | 6 #if defined(TARGET_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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); | 113 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 int64_t File::Write(const void* buffer, int64_t num_bytes) { | 117 int64_t File::Write(const void* buffer, int64_t num_bytes) { |
118 ASSERT(handle_->fd() >= 0); | 118 ASSERT(handle_->fd() >= 0); |
119 return TEMP_FAILURE_RETRY(write(handle_->fd(), buffer, num_bytes)); | 119 return TEMP_FAILURE_RETRY(write(handle_->fd(), buffer, num_bytes)); |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 bool File::VPrint(const char* format, va_list args) { | |
124 // Measure. | |
125 va_list measure_args; | |
126 va_copy(measure_args, args); | |
127 intptr_t len = vsnprintf(NULL, 0, format, measure_args); | |
128 va_end(measure_args); | |
129 | |
130 char* buffer = reinterpret_cast<char*>(malloc(len + 1)); | |
131 | |
132 // Print. | |
133 va_list print_args; | |
134 va_copy(print_args, args); | |
135 vsnprintf(buffer, len + 1, format, print_args); | |
136 va_end(print_args); | |
137 | |
138 bool result = WriteFully(buffer, len); | |
139 free(buffer); | |
140 return result; | |
141 } | |
siva
2017/02/22 23:37:16
This seems to be identical in all the different OS
rmacnak
2017/02/23 19:00:17
Windows is different from non-Windows because of v
| |
142 | |
143 | |
123 int64_t File::Position() { | 144 int64_t File::Position() { |
124 ASSERT(handle_->fd() >= 0); | 145 ASSERT(handle_->fd() >= 0); |
125 return NO_RETRY_EXPECTED(lseek64(handle_->fd(), 0, SEEK_CUR)); | 146 return NO_RETRY_EXPECTED(lseek64(handle_->fd(), 0, SEEK_CUR)); |
126 } | 147 } |
127 | 148 |
128 | 149 |
129 bool File::SetPosition(int64_t position) { | 150 bool File::SetPosition(int64_t position) { |
130 ASSERT(handle_->fd() >= 0); | 151 ASSERT(handle_->fd() >= 0); |
131 return NO_RETRY_EXPECTED(lseek64(handle_->fd(), position, SEEK_SET)) >= 0; | 152 return NO_RETRY_EXPECTED(lseek64(handle_->fd(), position, SEEK_SET)) >= 0; |
132 } | 153 } |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 return ((file_1_info.st_ino == file_2_info.st_ino) && | 602 return ((file_1_info.st_ino == file_2_info.st_ino) && |
582 (file_1_info.st_dev == file_2_info.st_dev)) | 603 (file_1_info.st_dev == file_2_info.st_dev)) |
583 ? File::kIdentical | 604 ? File::kIdentical |
584 : File::kDifferent; | 605 : File::kDifferent; |
585 } | 606 } |
586 | 607 |
587 } // namespace bin | 608 } // namespace bin |
588 } // namespace dart | 609 } // namespace dart |
589 | 610 |
590 #endif // defined(TARGET_OS_ANDROID) | 611 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |