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

Side by Side Diff: sdk/lib/io/directory_impl.dart

Issue 12610006: Renamed StreamSink to EventSink. Renamed signalError to addError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed inheritance back! Now create StreamSink instead of EventSink where we create them. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 class _Directory implements Directory { 7 class _Directory implements Directory {
8 static const CREATE_REQUEST = 0; 8 static const CREATE_REQUEST = 0;
9 static const DELETE_REQUEST = 1; 9 static const DELETE_REQUEST = 1;
10 static const EXISTS_REQUEST = 2; 10 static const EXISTS_REQUEST = 2;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 var controller = new StreamController<FileSystemEntity>(); 240 var controller = new StreamController<FileSystemEntity>();
241 241
242 List request = [ _Directory.LIST_REQUEST, path, recursive ]; 242 List request = [ _Directory.LIST_REQUEST, path, recursive ];
243 ReceivePort responsePort = new ReceivePort(); 243 ReceivePort responsePort = new ReceivePort();
244 // Use a separate directory service port for each listing as 244 // Use a separate directory service port for each listing as
245 // listing operations on the same directory can run in parallel. 245 // listing operations on the same directory can run in parallel.
246 _Directory._newServicePort().send(request, responsePort.toSendPort()); 246 _Directory._newServicePort().send(request, responsePort.toSendPort());
247 responsePort.receive((message, replyTo) { 247 responsePort.receive((message, replyTo) {
248 if (message is !List || message[RESPONSE_TYPE] is !int) { 248 if (message is !List || message[RESPONSE_TYPE] is !int) {
249 responsePort.close(); 249 responsePort.close();
250 controller.signalError(new DirectoryIOException("Internal error")); 250 controller.addError(new DirectoryIOException("Internal error"));
251 return; 251 return;
252 } 252 }
253 switch (message[RESPONSE_TYPE]) { 253 switch (message[RESPONSE_TYPE]) {
254 case LIST_FILE: 254 case LIST_FILE:
255 controller.add(new File(message[RESPONSE_PATH])); 255 controller.add(new File(message[RESPONSE_PATH]));
256 break; 256 break;
257 case LIST_DIRECTORY: 257 case LIST_DIRECTORY:
258 controller.add(new Directory(message[RESPONSE_PATH])); 258 controller.add(new Directory(message[RESPONSE_PATH]));
259 break; 259 break;
260 case LIST_ERROR: 260 case LIST_ERROR:
261 var errorType = 261 var errorType =
262 message[RESPONSE_ERROR][_ERROR_RESPONSE_ERROR_TYPE]; 262 message[RESPONSE_ERROR][_ERROR_RESPONSE_ERROR_TYPE];
263 if (errorType == _ILLEGAL_ARGUMENT_RESPONSE) { 263 if (errorType == _ILLEGAL_ARGUMENT_RESPONSE) {
264 controller.signalError(new ArgumentError()); 264 controller.addError(new ArgumentError());
265 } else if (errorType == _OSERROR_RESPONSE) { 265 } else if (errorType == _OSERROR_RESPONSE) {
266 var responseError = message[RESPONSE_ERROR]; 266 var responseError = message[RESPONSE_ERROR];
267 var err = new OSError( 267 var err = new OSError(
268 responseError[_OSERROR_RESPONSE_MESSAGE], 268 responseError[_OSERROR_RESPONSE_MESSAGE],
269 responseError[_OSERROR_RESPONSE_ERROR_CODE]); 269 responseError[_OSERROR_RESPONSE_ERROR_CODE]);
270 var errorPath = message[RESPONSE_PATH]; 270 var errorPath = message[RESPONSE_PATH];
271 if (errorPath == null) errorPath = path; 271 if (errorPath == null) errorPath = path;
272 controller.signalError( 272 controller.addError(
273 new DirectoryIOException("Directory listing failed", 273 new DirectoryIOException("Directory listing failed",
274 errorPath, 274 errorPath,
275 err)); 275 err));
276 } else { 276 } else {
277 controller.signalError(new DirectoryIOException("Internal error")); 277 controller.addError(new DirectoryIOException("Internal error"));
278 } 278 }
279 break; 279 break;
280 case LIST_DONE: 280 case LIST_DONE:
281 responsePort.close(); 281 responsePort.close();
282 controller.close(); 282 controller.close();
283 break; 283 break;
284 } 284 }
285 }); 285 });
286 286
287 return controller.stream; 287 return controller.stream;
(...skipping 30 matching lines...) Expand all
318 318
319 void _ensureDirectoryService() { 319 void _ensureDirectoryService() {
320 if (_directoryService == null) { 320 if (_directoryService == null) {
321 _directoryService = _newServicePort(); 321 _directoryService = _newServicePort();
322 } 322 }
323 } 323 }
324 324
325 final String _path; 325 final String _path;
326 SendPort _directoryService; 326 SendPort _directoryService;
327 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698