| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 5 |
| 6 class _DirectoryListingIsolate extends Isolate { | 6 class _DirectoryListingIsolate extends Isolate { |
| 7 | 7 |
| 8 _DirectoryListingIsolate() : super.heavy(); | 8 _DirectoryListingIsolate() : super.heavy(); |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 | 31 |
| 32 class _Directory implements Directory { | 32 class _Directory implements Directory { |
| 33 | 33 |
| 34 _Directory(String this._path); | 34 _Directory(String this._path); |
| 35 | 35 |
| 36 bool existsSync() { | 36 bool existsSync() { |
| 37 int exists = _exists(_path); | 37 int exists = _exists(_path); |
| 38 if (exists < 0) { | 38 if (exists < 0) { |
| 39 // TODO(ager): Supply a better error message. | |
| 40 throw new DirectoryException("Diretory exists test failed: $_path"); | 39 throw new DirectoryException("Diretory exists test failed: $_path"); |
| 41 } | 40 } |
| 42 return (exists == 1); | 41 return (exists == 1); |
| 43 } | 42 } |
| 44 | 43 |
| 45 void createSync() { | 44 void createSync() { |
| 46 if (!_create(_path)) { | 45 if (!_create(_path)) { |
| 47 // TODO(ager): Supply a better error message. | |
| 48 throw new DirectoryException("Directory creation failed: $_path"); | 46 throw new DirectoryException("Directory creation failed: $_path"); |
| 49 } | 47 } |
| 50 } | 48 } |
| 51 | 49 |
| 52 void deleteSync() { | 50 void deleteSync() { |
| 53 if (!_delete(_path)) { | 51 if (!_delete(_path)) { |
| 54 // TODO(ager): Supply a better error message. | |
| 55 throw new DirectoryException("Directory deletion failed: $_path"); | 52 throw new DirectoryException("Directory deletion failed: $_path"); |
| 56 } | 53 } |
| 57 } | 54 } |
| 58 | 55 |
| 59 void list([bool recursive = false]) { | 56 void list([bool recursive = false]) { |
| 60 new _DirectoryListingIsolate().spawn().then((port) { | 57 new _DirectoryListingIsolate().spawn().then((port) { |
| 61 // Build a map of parameters to the directory listing isolate. | 58 // Build a map of parameters to the directory listing isolate. |
| 62 Map listingParameters = new Map(); | 59 Map listingParameters = new Map(); |
| 63 listingParameters['dir'] = _path; | 60 listingParameters['dir'] = _path; |
| 64 listingParameters['recursive'] = recursive; | 61 listingParameters['recursive'] = recursive; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 bool _create(String path) native "Directory_Create"; | 145 bool _create(String path) native "Directory_Create"; |
| 149 bool _delete(String path) native "Directory_Delete"; | 146 bool _delete(String path) native "Directory_Delete"; |
| 150 | 147 |
| 151 var _dirHandler; | 148 var _dirHandler; |
| 152 var _fileHandler; | 149 var _fileHandler; |
| 153 var _doneHandler; | 150 var _doneHandler; |
| 154 var _errorHandler; | 151 var _errorHandler; |
| 155 | 152 |
| 156 String _path; | 153 String _path; |
| 157 } | 154 } |
| OLD | NEW |