OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #ifndef RUNTIME_BIN_FILE_H_ | 5 #ifndef RUNTIME_BIN_FILE_H_ |
6 #define RUNTIME_BIN_FILE_H_ | 6 #define RUNTIME_BIN_FILE_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 int64_t Write(const void* buffer, int64_t num_bytes); | 115 int64_t Write(const void* buffer, int64_t num_bytes); |
116 | 116 |
117 // ReadFully and WriteFully do attempt to transfer num_bytes to/from | 117 // ReadFully and WriteFully do attempt to transfer num_bytes to/from |
118 // the buffer. In the event of short accesses they will loop internally until | 118 // the buffer. In the event of short accesses they will loop internally until |
119 // the whole buffer has been transferred or an error occurs. If an error | 119 // the whole buffer has been transferred or an error occurs. If an error |
120 // occurred the result will be set to false. | 120 // occurred the result will be set to false. |
121 bool ReadFully(void* buffer, int64_t num_bytes); | 121 bool ReadFully(void* buffer, int64_t num_bytes); |
122 bool WriteFully(const void* buffer, int64_t num_bytes); | 122 bool WriteFully(const void* buffer, int64_t num_bytes); |
123 bool WriteByte(uint8_t byte) { return WriteFully(&byte, 1); } | 123 bool WriteByte(uint8_t byte) { return WriteFully(&byte, 1); } |
124 | 124 |
| 125 bool Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3) { |
| 126 va_list args; |
| 127 va_start(args, format); |
| 128 bool result = VPrint(format, args); |
| 129 va_end(args); |
| 130 return result; |
| 131 } |
| 132 bool VPrint(const char* format, va_list args); |
| 133 |
125 // Get the length of the file. Returns a negative value if the length cannot | 134 // Get the length of the file. Returns a negative value if the length cannot |
126 // be determined (e.g. not seekable device). | 135 // be determined (e.g. not seekable device). |
127 int64_t Length(); | 136 int64_t Length(); |
128 | 137 |
129 // Get the current position in the file. | 138 // Get the current position in the file. |
130 // Returns a negative value if position cannot be determined. | 139 // Returns a negative value if position cannot be determined. |
131 int64_t Position(); | 140 int64_t Position(); |
132 | 141 |
133 // Set the byte position in the file. | 142 // Set the byte position in the file. |
134 bool SetPosition(int64_t position); | 143 bool SetPosition(int64_t position); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 Dart_WeakPersistentHandle weak_handle_; | 267 Dart_WeakPersistentHandle weak_handle_; |
259 | 268 |
260 friend class ReferenceCounted<File>; | 269 friend class ReferenceCounted<File>; |
261 DISALLOW_COPY_AND_ASSIGN(File); | 270 DISALLOW_COPY_AND_ASSIGN(File); |
262 }; | 271 }; |
263 | 272 |
264 } // namespace bin | 273 } // namespace bin |
265 } // namespace dart | 274 } // namespace dart |
266 | 275 |
267 #endif // RUNTIME_BIN_FILE_H_ | 276 #endif // RUNTIME_BIN_FILE_H_ |
OLD | NEW |