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

Unified Diff: runtime/bin/directory_impl.dart

Issue 8277033: Add exists, create and delete to directory implementation on Linux and Mac. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows build. Created 9 years, 2 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 | « runtime/bin/directory.dart ('k') | runtime/bin/directory_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_impl.dart
diff --git a/runtime/bin/directory_impl.dart b/runtime/bin/directory_impl.dart
index e334c0971b043388ee805c9ec7c15bcfcde8395b..3655b9071db5ec93b28e56bd3724c1940edfece9 100644
--- a/runtime/bin/directory_impl.dart
+++ b/runtime/bin/directory_impl.dart
@@ -4,6 +4,7 @@
class DirectoryException {
+ String toString() { return "DirectoryException: $message"; }
const DirectoryException(String this.message);
final String message;
}
@@ -36,13 +37,36 @@ class _DirectoryListingIsolate extends Isolate {
class _Directory implements Directory {
- _Directory(String this._dir);
+ _Directory(String this._path);
+
+ bool exists() {
+ int exists = _exists(_path);
+ if (exists < 0) {
+ // TODO(ager): Supply a better error message.
+ throw new DirectoryException("Diretory exists test failed: $_path");
+ }
+ return (exists == 1);
+ }
+
+ void create() {
+ if (!_create(_path)) {
+ // TODO(ager): Supply a better error message.
+ throw new DirectoryException("Directory creation failed: $_path");
+ }
+ }
+
+ void delete() {
+ if (!_delete(_path)) {
+ // TODO(ager): Supply a better error message.
+ throw new DirectoryException("Directory deletion failed: $_path");
+ }
+ }
void list([bool recursive = false]) {
new _DirectoryListingIsolate().spawn().then((port) {
// Build a map of parameters to the directory listing isolate.
Map listingParameters = new Map();
- listingParameters['dir'] = _dir;
+ listingParameters['dir'] = _path;
listingParameters['recursive'] = recursive;
// Setup ports to receive messages from listing.
@@ -118,10 +142,16 @@ class _Directory implements Directory {
}
}
+ String get path() { return _path; }
+
+ bool _exists(String path) native "Directory_Exists";
+ bool _create(String path) native "Directory_Create";
+ bool _delete(String path) native "Directory_Delete";
+
var _dirHandler;
var _fileHandler;
var _doneHandler;
var _errorHandler;
- String _dir;
+ String _path;
}
« no previous file with comments | « runtime/bin/directory.dart ('k') | runtime/bin/directory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698