Index: runtime/lib/uri.cc |
diff --git a/runtime/lib/uri.cc b/runtime/lib/uri.cc |
index f75d2ecc4d242a50a219404a12c631c3066a6256..a883353ebb9f577cd63d446f85f50f5c8f7f8974 100644 |
--- a/runtime/lib/uri.cc |
+++ b/runtime/lib/uri.cc |
@@ -2,6 +2,8 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
+#include "bin/directory.h" |
+#include "bin/utils.h" |
#include "vm/bootstrap_natives.h" |
#include "vm/native_entry.h" |
#include "vm/object.h" |
@@ -9,11 +11,27 @@ |
namespace dart { |
DEFINE_NATIVE_ENTRY(Uri_isWindowsPlatform, 0) { |
-#if defined(_WIN32) |
+#if defined(TARGET_OS_WINDOWS) |
return Bool::True().raw(); |
#else |
return Bool::False().raw(); |
#endif |
} |
+ |
+DEFINE_NATIVE_ENTRY(Uri_currentDirectory, 0) { |
+ char* current = bin::Directory::Current(); |
+ if (current == NULL) { |
+ bin::OSError err; |
+ const String& error = String::Handle(String::NewFormatted( |
+ "Error determining current directory: %s", err.message())); |
+ const Array& args = Array::Handle(Array::New(1)); |
+ args.SetAt(0, error); |
+ Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
+ } |
+ |
+ const String& result = String::Handle(String::New(current)); |
+ return result.raw(); |
+} |
+ |
} // namespace dart |