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

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

Issue 1904553006: Fix strong mode errors in dart:io. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix directory_list rename for dartium. Created 4 years, 7 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
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/io_patch.dart ('k') | sdk/lib/io/http_impl.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 final String path; 8 final String path;
9 9
10 _Directory(this.path) { 10 _Directory(this.path) {
11 if (path is! String) { 11 if (path is! String) {
12 throw new ArgumentError('${Error.safeToString(path)} ' 12 throw new ArgumentError('${Error.safeToString(path)} '
13 'is not a String'); 13 'is not a String');
14 } 14 }
15 } 15 }
16 16
17 external static _current(); 17 external static _current();
18 external static _setCurrent(path); 18 external static _setCurrent(path);
19 external static _createTemp(String path); 19 external static _createTemp(String path);
20 external static String _systemTemp(); 20 external static String _systemTemp();
21 external static _exists(String path); 21 external static _exists(String path);
22 external static _create(String path); 22 external static _create(String path);
23 external static _deleteNative(String path, bool recursive); 23 external static _deleteNative(String path, bool recursive);
24 external static _rename(String path, String newPath); 24 external static _rename(String path, String newPath);
25 external static List _list(String path, bool recursive, bool followLinks); 25 external static void _fillWithDirectoryListing(
26 List<FileSystemEntity> list, String path, bool recursive,
27 bool followLinks);
26 28
27 static Directory get current { 29 static Directory get current {
28 var result = _current(); 30 var result = _current();
29 if (result is OSError) { 31 if (result is OSError) {
30 throw new FileSystemException( 32 throw new FileSystemException(
31 "Getting current working directory failed", "", result); 33 "Getting current working directory failed", "", result);
32 } 34 }
33 return new _Directory(result); 35 return new _Directory(result);
34 } 36 }
35 37
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 217 }
216 218
217 Stream<FileSystemEntity> list({bool recursive: false, 219 Stream<FileSystemEntity> list({bool recursive: false,
218 bool followLinks: true}) { 220 bool followLinks: true}) {
219 return new _AsyncDirectoryLister( 221 return new _AsyncDirectoryLister(
220 FileSystemEntity._ensureTrailingPathSeparators(path), 222 FileSystemEntity._ensureTrailingPathSeparators(path),
221 recursive, 223 recursive,
222 followLinks).stream; 224 followLinks).stream;
223 } 225 }
224 226
225 List listSync({bool recursive: false, bool followLinks: true}) { 227 List<FileSystemEntity> listSync(
228 {bool recursive: false, bool followLinks: true}) {
226 if (recursive is! bool || followLinks is! bool) { 229 if (recursive is! bool || followLinks is! bool) {
227 throw new ArgumentError(); 230 throw new ArgumentError();
228 } 231 }
229 return _list( 232 var result = <FileSystemEntity>[];
233 _fillWithDirectoryListing(
234 result,
230 FileSystemEntity._ensureTrailingPathSeparators(path), 235 FileSystemEntity._ensureTrailingPathSeparators(path),
231 recursive, 236 recursive,
232 followLinks); 237 followLinks);
238 return result;
233 } 239 }
234 240
235 String toString() => "Directory: '$path'"; 241 String toString() => "Directory: '$path'";
236 242
237 bool _isErrorResponse(response) => 243 bool _isErrorResponse(response) =>
238 response is List && response[0] != _SUCCESS_RESPONSE; 244 response is List && response[0] != _SUCCESS_RESPONSE;
239 245
240 _exceptionOrErrorFromResponse(response, String message) { 246 _exceptionOrErrorFromResponse(response, String message) {
241 assert(_isErrorResponse(response)); 247 assert(_isErrorResponse(response));
242 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { 248 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 controller.addError( 419 controller.addError(
414 new FileSystemException("Directory listing failed", 420 new FileSystemException("Directory listing failed",
415 errorPath, 421 errorPath,
416 err)); 422 err));
417 } else { 423 } else {
418 controller.addError( 424 controller.addError(
419 new FileSystemException("Internal error")); 425 new FileSystemException("Internal error"));
420 } 426 }
421 } 427 }
422 } 428 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/io_patch.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698