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_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include <fcntl.h> // NOLINT | 10 #include <fcntl.h> // NOLINT |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } else { | 178 } else { |
179 // If we've done _setmode(fd, _O_WTEXT) then _write() expects | 179 // If we've done _setmode(fd, _O_WTEXT) then _write() expects |
180 // a buffer of wchar_t with an even unmber of bytes. | 180 // a buffer of wchar_t with an even unmber of bytes. |
181 Utf8ToWideScope wide(reinterpret_cast<const char*>(buffer), num_bytes); | 181 Utf8ToWideScope wide(reinterpret_cast<const char*>(buffer), num_bytes); |
182 ASSERT((wide.size_in_bytes() % 2) == 0); | 182 ASSERT((wide.size_in_bytes() % 2) == 0); |
183 return _write(fd, wide.wide(), wide.size_in_bytes()); | 183 return _write(fd, wide.wide(), wide.size_in_bytes()); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 | 187 |
| 188 bool File::VPrint(const char* format, va_list args) { |
| 189 // Measure. |
| 190 va_list measure_args; |
| 191 va_copy(measure_args, args); |
| 192 intptr_t len = _vscprintf(format, measure_args); |
| 193 va_end(measure_args); |
| 194 |
| 195 char* buffer = reinterpret_cast<char*>(malloc(len + 1)); |
| 196 |
| 197 // Print. |
| 198 va_list print_args; |
| 199 va_copy(print_args, args); |
| 200 _vsnprintf(buffer, len + 1, format, print_args); |
| 201 va_end(print_args); |
| 202 |
| 203 bool result = WriteFully(buffer, len); |
| 204 free(buffer); |
| 205 return result; |
| 206 } |
| 207 |
| 208 |
188 int64_t File::Position() { | 209 int64_t File::Position() { |
189 ASSERT(handle_->fd() >= 0); | 210 ASSERT(handle_->fd() >= 0); |
190 return _lseeki64(handle_->fd(), 0, SEEK_CUR); | 211 return _lseeki64(handle_->fd(), 0, SEEK_CUR); |
191 } | 212 } |
192 | 213 |
193 | 214 |
194 bool File::SetPosition(int64_t position) { | 215 bool File::SetPosition(int64_t position) { |
195 ASSERT(handle_->fd() >= 0); | 216 ASSERT(handle_->fd() >= 0); |
196 return _lseeki64(handle_->fd(), position, SEEK_SET) >= 0; | 217 return _lseeki64(handle_->fd(), position, SEEK_SET) >= 0; |
197 } | 218 } |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 return kIdentical; | 825 return kIdentical; |
805 } else { | 826 } else { |
806 return kDifferent; | 827 return kDifferent; |
807 } | 828 } |
808 } | 829 } |
809 | 830 |
810 } // namespace bin | 831 } // namespace bin |
811 } // namespace dart | 832 } // namespace dart |
812 | 833 |
813 #endif // defined(TARGET_OS_WINDOWS) | 834 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |