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 #include "bin/directory.h" |
| 6 #include "bin/utils.h" |
5 #include "vm/bootstrap_natives.h" | 7 #include "vm/bootstrap_natives.h" |
6 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
7 #include "vm/object.h" | 9 #include "vm/object.h" |
8 | 10 |
9 namespace dart { | 11 namespace dart { |
10 | 12 |
11 DEFINE_NATIVE_ENTRY(Uri_isWindowsPlatform, 0) { | 13 DEFINE_NATIVE_ENTRY(Uri_isWindowsPlatform, 0) { |
12 #if defined(_WIN32) | 14 #if defined(TARGET_OS_WINDOWS) |
13 return Bool::True().raw(); | 15 return Bool::True().raw(); |
14 #else | 16 #else |
15 return Bool::False().raw(); | 17 return Bool::False().raw(); |
16 #endif | 18 #endif |
17 } | 19 } |
18 | 20 |
| 21 |
| 22 DEFINE_NATIVE_ENTRY(Uri_currentDirectory, 0) { |
| 23 char* current = bin::Directory::Current(); |
| 24 if (current == NULL) { |
| 25 bin::OSError err; |
| 26 const String& error = String::Handle(String::NewFormatted( |
| 27 "Error determining current directory: %s", err.message())); |
| 28 const Array& args = Array::Handle(Array::New(1)); |
| 29 args.SetAt(0, error); |
| 30 Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
| 31 } |
| 32 |
| 33 const String& result = String::Handle(String::New(current)); |
| 34 return result.raw(); |
| 35 } |
| 36 |
19 } // namespace dart | 37 } // namespace dart |
OLD | NEW |