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

Unified Diff: runtime/bin/directory_impl.dart

Issue 8417023: Add type checks to directory listing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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') | tests/standalone/src/DirectoryInvalidArgumentsTest.dart » ('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 127d68b475f7b67bb9e25a09ead14e6ef74bfbf7..f4f062c0e39e64aee347b6b42dff698d19b1ed0e 100644
--- a/runtime/bin/directory_impl.dart
+++ b/runtime/bin/directory_impl.dart
@@ -3,30 +3,23 @@
// BSD-style license that can be found in the LICENSE file.
-class DirectoryException {
- String toString() { return "DirectoryException: $message"; }
- const DirectoryException(String this.message);
- final String message;
-}
-
-
class _DirectoryListingIsolate extends Isolate {
_DirectoryListingIsolate() : super.heavy();
void main() {
port.receive((message, replyTo) {
- _list(message['dir'],
- message['recursive'],
- message['dirPort'],
- message['filePort'],
- message['donePort'],
- message['errorPort']);
- replyTo.send(true);
+ bool started = _list(message['dir'],
+ message['recursive'],
+ message['dirPort'],
+ message['filePort'],
+ message['donePort'],
+ message['errorPort']);
+ replyTo.send(started);
});
}
- void _list(String dir,
+ bool _list(String dir,
bool recursive,
SendPort dirPort,
SendPort filePort,
@@ -91,14 +84,14 @@ class _Directory implements Directory {
listingParameters['filePort'] = filePort.toSendPort();
}
if (_doneHandler !== null) {
- donePort = new ReceivePort();
+ donePort = new ReceivePort.singleShot();
donePort.receive((bool completed, ignored) {
_doneHandler(completed);
});
listingParameters['donePort'] = donePort.toSendPort();
}
if (_errorHandler !== null) {
- errorPort = new ReceivePort();
+ errorPort = new ReceivePort.singleShot();
errorPort.receive((String error, ignored) {
_errorHandler(error);
});
@@ -108,10 +101,16 @@ class _Directory implements Directory {
// Close ports when listing is done.
ReceivePort closePortsPort = new ReceivePort();
closePortsPort.receive((message, replyTo) {
+ if (!message) {
+ errorPort.toSendPort().send(
+ "Failed to list directory: $_path recursive: $recursive");
+ donePort.toSendPort().send(false);
+ } else {
+ _closePort(errorPort);
+ _closePort(donePort);
+ }
_closePort(dirPort);
_closePort(filePort);
Søren Gjesse 2011/10/28 13:05:55 Shouldn't the error port be closed if everything e
Mads Ager (google) 2011/10/28 15:58:16 It is on line 109. If listing does not start the s
- _closePort(donePort);
- _closePort(errorPort);
_closePort(closePortsPort);
});
« no previous file with comments | « runtime/bin/directory.dart ('k') | tests/standalone/src/DirectoryInvalidArgumentsTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698