Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: sdk/lib/io/directory_impl.dart

Issue 13896034: Add the ability to change the working directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tests Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/directory.dart ('k') | tests/standalone/io/directory_chdir_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « sdk/lib/io/directory.dart ('k') | tests/standalone/io/directory_chdir_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698