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 "vm/os.h" | 5 #include "vm/os.h" |
6 | 6 |
7 #include <time.h> | 7 #include <time.h> |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 | 171 |
172 void OS::Print(const char* format, ...) { | 172 void OS::Print(const char* format, ...) { |
173 va_list args; | 173 va_list args; |
174 va_start(args, format); | 174 va_start(args, format); |
175 VFPrint(stdout, format, args); | 175 VFPrint(stdout, format, args); |
176 va_end(args); | 176 va_end(args); |
177 } | 177 } |
178 | 178 |
179 | 179 |
| 180 void OS::FPrint(FILE* stream, const char* format, ...) { |
| 181 va_list args; |
| 182 va_start(args, format); |
| 183 VFPrint(stream, format, args); |
| 184 va_end(args); |
| 185 } |
| 186 |
| 187 |
180 void OS::VFPrint(FILE* stream, const char* format, va_list args) { | 188 void OS::VFPrint(FILE* stream, const char* format, va_list args) { |
181 vfprintf(stream, format, args); | 189 vfprintf(stream, format, args); |
182 fflush(stream); | 190 fflush(stream); |
183 } | 191 } |
184 | 192 |
185 | 193 |
186 int OS::SNPrint(char* str, size_t size, const char* format, ...) { | 194 int OS::SNPrint(char* str, size_t size, const char* format, ...) { |
187 va_list args; | 195 va_list args; |
188 va_start(args, format); | 196 va_start(args, format); |
189 int retval = VSNPrint(str, size, format, args); | 197 int retval = VSNPrint(str, size, format, args); |
(...skipping 21 matching lines...) Expand all Loading... |
211 } | 219 } |
212 // Make sure to zero-terminate the string if the output was | 220 // Make sure to zero-terminate the string if the output was |
213 // truncated or if there was an error. | 221 // truncated or if there was an error. |
214 if (written >= size) { | 222 if (written >= size) { |
215 str[size - 1] = '\0'; | 223 str[size - 1] = '\0'; |
216 } | 224 } |
217 return written; | 225 return written; |
218 } | 226 } |
219 | 227 |
220 | 228 |
| 229 FILE* OS::FOpen(const char* path, const char* mode) { |
| 230 FILE* result; |
| 231 if (fopen_s(&result, path, mode) == 0) return result; |
| 232 return NULL; |
| 233 } |
| 234 |
| 235 |
221 void OS::PrintErr(const char* format, ...) { | 236 void OS::PrintErr(const char* format, ...) { |
222 va_list args; | 237 va_list args; |
223 va_start(args, format); | 238 va_start(args, format); |
224 VFPrint(stderr, format, args); | 239 VFPrint(stderr, format, args); |
225 va_end(args); | 240 va_end(args); |
226 } | 241 } |
227 | 242 |
228 | 243 |
229 void OS::InitOnce() { | 244 void OS::InitOnce() { |
230 // TODO(5411554): For now we check that initonce is called only once, | 245 // TODO(5411554): For now we check that initonce is called only once, |
(...skipping 14 matching lines...) Expand all Loading... |
245 void OS::Abort() { | 260 void OS::Abort() { |
246 abort(); | 261 abort(); |
247 } | 262 } |
248 | 263 |
249 | 264 |
250 void OS::Exit(int code) { | 265 void OS::Exit(int code) { |
251 exit(code); | 266 exit(code); |
252 } | 267 } |
253 | 268 |
254 } // namespace dart | 269 } // namespace dart |
OLD | NEW |