Index: sdk/lib/io/directory_impl.dart |
diff --git a/sdk/lib/io/directory_impl.dart b/sdk/lib/io/directory_impl.dart |
index 3aaf2194d51ee9a1cefb4b0204dfa2c0d19eb01b..72ca527dcab23725d1c45612d4d47ec5191b60af 100644 |
--- a/sdk/lib/io/directory_impl.dart |
+++ b/sdk/lib/io/directory_impl.dart |
@@ -18,9 +18,9 @@ class _Directory implements Directory { |
_Directory(String this._path); |
_Directory.fromPath(Path path) : this(path.toNativePath()); |
- _Directory.current() : this(_current()); |
external static String _current(); |
+ external static _setCurrent(String path); |
external static _createTemp(String template); |
external static int _exists(String path); |
external static _create(String path); |
@@ -29,6 +29,18 @@ class _Directory implements Directory { |
external static List _list(String path, bool recursive, bool followLinks); |
external static SendPort _newServicePort(); |
+ static Directory get current => new _Directory(_current()); |
+ |
+ static void set current(path) { |
+ if (path is Directory) path = path.path; |
+ var result = _setCurrent(path); |
+ if (result is ArgumentError) throw result; |
+ if (result is OSError) { |
+ throw new DirectoryIOException( |
+ "Setting current working directory failed", path, result); |
+ } |
+ } |
+ |
Future<bool> exists() { |
_ensureDirectoryService(); |
List request = new List(2); |