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

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

Issue 23702037: Fix error handling when current working directory is deleted. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix type of _Directory._current Created 7 years, 3 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
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/directory_chdir_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 extends FileSystemEntity implements Directory { 7 class _Directory extends FileSystemEntity 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;
11 static const CREATE_TEMP_REQUEST = 3; 11 static const CREATE_TEMP_REQUEST = 3;
12 static const LIST_START_REQUEST = 4; 12 static const LIST_START_REQUEST = 4;
13 static const LIST_NEXT_REQUEST = 5; 13 static const LIST_NEXT_REQUEST = 5;
14 static const LIST_STOP_REQUEST = 6; 14 static const LIST_STOP_REQUEST = 6;
15 static const RENAME_REQUEST = 7; 15 static const RENAME_REQUEST = 7;
16 16
17 final String path; 17 final String path;
18 SendPort _directoryService; 18 SendPort _directoryService;
19 19
20 _Directory(String this.path) { 20 _Directory(String this.path) {
21 if (path is! String) { 21 if (path is! String) {
22 throw new ArgumentError('${Error.safeToString(path)} ' 22 throw new ArgumentError('${Error.safeToString(path)} '
23 'is not a String'); 23 'is not a String');
24 } 24 }
25 } 25 }
26 26
27 external static String _current(); 27 external static _current();
28 external static _setCurrent(path); 28 external static _setCurrent(path);
29 external static _createTemp(String template); 29 external static _createTemp(String template);
30 external static int _exists(String path); 30 external static int _exists(String path);
31 external static _create(String path); 31 external static _create(String path);
32 external static _deleteNative(String path, bool recursive); 32 external static _deleteNative(String path, bool recursive);
33 external static _rename(String path, String newPath); 33 external static _rename(String path, String newPath);
34 external static List _list(String path, bool recursive, bool followLinks); 34 external static List _list(String path, bool recursive, bool followLinks);
35 external static SendPort _newServicePort(); 35 external static SendPort _newServicePort();
36 36
37 static Directory get current => new _Directory(_current()); 37 static Directory get current {
38 var result = _current();
39 if (result is OSError) {
40 throw new DirectoryException(
41 "Getting current working directory failed", "", result);
42 }
43 return new _Directory(result);
44 }
38 45
39 static void set current(path) { 46 static void set current(path) {
40 if (path is Directory) path = path.path; 47 if (path is Directory) path = path.path;
41 var result = _setCurrent(path); 48 var result = _setCurrent(path);
42 if (result is ArgumentError) throw result; 49 if (result is ArgumentError) throw result;
43 if (result is OSError) { 50 if (result is OSError) {
44 throw new DirectoryException( 51 throw new DirectoryException(
45 "Setting current working directory failed", path, result); 52 "Setting current working directory failed", path, result);
46 } 53 }
47 } 54 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 controller.addError( 406 controller.addError(
400 new DirectoryException("Directory listing failed", 407 new DirectoryException("Directory listing failed",
401 errorPath, 408 errorPath,
402 err)); 409 err));
403 } else { 410 } else {
404 controller.addError( 411 controller.addError(
405 new DirectoryException("Internal error")); 412 new DirectoryException("Internal error"));
406 } 413 }
407 } 414 }
408 } 415 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/directory_chdir_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698