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
3// BSD-style license that can be found in the LICENSE file.
4
5#include "platform/globals.h"
6#if defined(HOST_OS_ANDROID)
7
8#include "platform/utils.h"
9
10namespace dart {
11
12char* Utils::StrNDup(const char* s, intptr_t n) {
13 return strndup(s, n);
14}
15
16char* Utils::StrDup(const char* s) {
17 return strdup(s);
18}
19
20intptr_t Utils::StrNLen(const char* s, intptr_t n) {
21 return strnlen(s, n);
22}
23
24int Utils::SNPrint(char* str, size_t size, const char* format, ...) {
25 va_list args;
26 va_start(args, format);
27 int retval = VSNPrint(str, size, format, args);
28 va_end(args);
29 return retval;
30}
31
32int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
33 int retval = vsnprintf(str, size, format, args);
34 if (retval < 0) {
35 FATAL1("Fatal error in Utils::VSNPrint with format '%s'", format);
36 }
37 return retval;
38}
39
40int Utils::Close(int fildes) {
41 return close(fildes);
42}
43size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
44 return read(filedes, buf, nbyte);
45}
46int Utils::Unlink(const char* path) {
47 return unlink(path);
48}
49
50} // namespace dart
51
52#endif // defined(HOST_OS_ANDROID)
53