Index: runtime/bin/file_macos.cc |
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc |
index 676f8c309ef80b804c2f07e3468775f121663015..7309da055fa272c3157f2bc90e7d0aa929ca51e1 100644 |
--- a/runtime/bin/file_macos.cc |
+++ b/runtime/bin/file_macos.cc |
@@ -122,6 +122,26 @@ int64_t File::Write(const void* buffer, int64_t num_bytes) { |
} |
+bool File::VPrint(const char* format, va_list args) { |
+ // Measure. |
+ va_list measure_args; |
+ va_copy(measure_args, args); |
+ intptr_t len = vsnprintf(NULL, 0, format, measure_args); |
+ va_end(measure_args); |
+ |
+ char* buffer = reinterpret_cast<char*>(malloc(len + 1)); |
+ |
+ // Print. |
+ va_list print_args; |
+ va_copy(print_args, args); |
+ vsnprintf(buffer, len + 1, format, print_args); |
+ va_end(print_args); |
+ |
+ bool result = WriteFully(buffer, len); |
+ free(buffer); |
+ return result; |
+} |
+ |
int64_t File::Position() { |
ASSERT(handle_->fd() >= 0); |
return lseek(handle_->fd(), 0, SEEK_CUR); |