OLD | NEW |
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #if defined(FLETCH_TARGET_OS_WIN) | 5 #if defined(DARTINO_TARGET_OS_WIN) |
6 | 6 |
7 #include "src/vm/natives.h" | 7 #include "src/vm/natives.h" |
8 | 8 |
9 #include <direct.h> | 9 #include <direct.h> |
10 | 10 |
11 #include "src/shared/platform.h" | 11 #include "src/shared/platform.h" |
12 | 12 |
13 #include "src/vm/process.h" | 13 #include "src/vm/process.h" |
14 | 14 |
15 namespace fletch { | 15 namespace dartino { |
16 | 16 |
17 BEGIN_NATIVE(UriBase) { | 17 BEGIN_NATIVE(UriBase) { |
18 char* buffer = reinterpret_cast<char*>(malloc(MAXPATHLEN + 1)); | 18 char* buffer = reinterpret_cast<char*>(malloc(MAXPATHLEN + 1)); |
19 char* path = _getcwd(buffer, MAXPATHLEN); | 19 char* path = _getcwd(buffer, MAXPATHLEN); |
20 if (path == NULL) FATAL("Failed to get current working directory."); | 20 if (path == NULL) FATAL("Failed to get current working directory."); |
21 int length = strlen(path); | 21 int length = strlen(path); |
22 if (path[length - 1] != '\\') { | 22 if (path[length - 1] != '\\') { |
23 path[length++] = '\\'; | 23 path[length++] = '\\'; |
24 path[length] = 0; | 24 path[length] = 0; |
25 } | 25 } |
26 Object* result = process->NewStringFromAscii(List<const char>(path, length)); | 26 Object* result = process->NewStringFromAscii(List<const char>(path, length)); |
27 free(buffer); | 27 free(buffer); |
28 return result; | 28 return result; |
29 } | 29 } |
30 END_NATIVE() | 30 END_NATIVE() |
31 | 31 |
32 } // namespace fletch | 32 } // namespace dartino |
33 | 33 |
34 #endif // defined FLETCH_TARGET_OS_WIN | 34 #endif // defined DARTINO_TARGET_OS_WIN |
OLD | NEW |