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

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

Issue 816353012: Mark all private functions in dart: libraries as invisible (*sniff*). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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/io/data_transformer.dart ('k') | sdk/lib/io/file_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) {
(...skipping 26 matching lines...) Expand all
37 if (path is Directory) path = path.path; 37 if (path is Directory) path = path.path;
38 var result = _setCurrent(path); 38 var result = _setCurrent(path);
39 if (result is ArgumentError) throw result; 39 if (result is ArgumentError) throw result;
40 if (result is OSError) { 40 if (result is OSError) {
41 throw new FileSystemException( 41 throw new FileSystemException(
42 "Setting current working directory failed", path, result); 42 "Setting current working directory failed", path, result);
43 } 43 }
44 } 44 }
45 45
46 Future<bool> exists() { 46 Future<bool> exists() {
47 return _IOService.dispatch(_DIRECTORY_EXISTS, [path]).then((response) { 47 return _IOService._dispatch(_DIRECTORY_EXISTS, [path]).then((response) {
48 if (_isErrorResponse(response)) { 48 if (_isErrorResponse(response)) {
49 throw _exceptionOrErrorFromResponse(response, "Exists failed"); 49 throw _exceptionOrErrorFromResponse(response, "Exists failed");
50 } 50 }
51 return response == 1; 51 return response == 1;
52 }); 52 });
53 } 53 }
54 54
55 bool existsSync() { 55 bool existsSync() {
56 var result = _exists(path); 56 var result = _exists(path);
57 if (result is OSError) { 57 if (result is OSError) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (exists) return this; 96 if (exists) return this;
97 if (path != parent.path) { 97 if (path != parent.path) {
98 return parent.create(recursive: true).then((_) { 98 return parent.create(recursive: true).then((_) {
99 return create(); 99 return create();
100 }); 100 });
101 } else { 101 } else {
102 return create(); 102 return create();
103 } 103 }
104 }); 104 });
105 } else { 105 } else {
106 return _IOService.dispatch(_DIRECTORY_CREATE, [path]).then((response) { 106 return _IOService._dispatch(_DIRECTORY_CREATE, [path]).then((response) {
107 if (_isErrorResponse(response)) { 107 if (_isErrorResponse(response)) {
108 throw _exceptionOrErrorFromResponse(response, "Creation failed"); 108 throw _exceptionOrErrorFromResponse(response, "Creation failed");
109 } 109 }
110 return this; 110 return this;
111 }); 111 });
112 } 112 }
113 } 113 }
114 114
115 void createSync({bool recursive: false}) { 115 void createSync({bool recursive: false}) {
116 if (recursive) { 116 if (recursive) {
(...skipping 16 matching lines...) Expand all
133 throw new ArgumentError( 133 throw new ArgumentError(
134 "Directory.createTemp called with an empty path. " 134 "Directory.createTemp called with an empty path. "
135 "To use the system temp directory, use Directory.systemTemp"); 135 "To use the system temp directory, use Directory.systemTemp");
136 } 136 }
137 String fullPrefix; 137 String fullPrefix;
138 if (path.endsWith('/') || (Platform.isWindows && path.endsWith('\\'))) { 138 if (path.endsWith('/') || (Platform.isWindows && path.endsWith('\\'))) {
139 fullPrefix = "$path$prefix"; 139 fullPrefix = "$path$prefix";
140 } else { 140 } else {
141 fullPrefix = "$path${Platform.pathSeparator}$prefix"; 141 fullPrefix = "$path${Platform.pathSeparator}$prefix";
142 } 142 }
143 return _IOService.dispatch(_DIRECTORY_CREATE_TEMP, [fullPrefix]) 143 return _IOService._dispatch(_DIRECTORY_CREATE_TEMP, [fullPrefix])
144 .then((response) { 144 .then((response) {
145 if (_isErrorResponse(response)) { 145 if (_isErrorResponse(response)) {
146 throw _exceptionOrErrorFromResponse( 146 throw _exceptionOrErrorFromResponse(
147 response, "Creation of temporary directory failed"); 147 response, "Creation of temporary directory failed");
148 } 148 }
149 return new Directory(response); 149 return new Directory(response);
150 }); 150 });
151 } 151 }
152 152
153 Directory createTempSync([String prefix]) { 153 Directory createTempSync([String prefix]) {
(...skipping 12 matching lines...) Expand all
166 var result = _createTemp(fullPrefix); 166 var result = _createTemp(fullPrefix);
167 if (result is OSError) { 167 if (result is OSError) {
168 throw new FileSystemException("Creation of temporary directory failed", 168 throw new FileSystemException("Creation of temporary directory failed",
169 fullPrefix, 169 fullPrefix,
170 result); 170 result);
171 } 171 }
172 return new Directory(result); 172 return new Directory(result);
173 } 173 }
174 174
175 Future<Directory> _delete({bool recursive: false}) { 175 Future<Directory> _delete({bool recursive: false}) {
176 return _IOService.dispatch(_DIRECTORY_DELETE, [path, recursive]) 176 return _IOService._dispatch(_DIRECTORY_DELETE, [path, recursive])
177 .then((response) { 177 .then((response) {
178 if (_isErrorResponse(response)) { 178 if (_isErrorResponse(response)) {
179 throw _exceptionOrErrorFromResponse(response, "Deletion failed"); 179 throw _exceptionOrErrorFromResponse(response, "Deletion failed");
180 } 180 }
181 return this; 181 return this;
182 }); 182 });
183 } 183 }
184 184
185 void _deleteSync({bool recursive: false}) { 185 void _deleteSync({bool recursive: false}) {
186 var result = _deleteNative(path, recursive); 186 var result = _deleteNative(path, recursive);
187 if (result is OSError) { 187 if (result is OSError) {
188 throw new FileSystemException("Deletion failed", path, result); 188 throw new FileSystemException("Deletion failed", path, result);
189 } 189 }
190 } 190 }
191 191
192 Future<Directory> rename(String newPath) { 192 Future<Directory> rename(String newPath) {
193 return _IOService.dispatch(_DIRECTORY_RENAME, [path, newPath]) 193 return _IOService._dispatch(_DIRECTORY_RENAME, [path, newPath])
194 .then((response) { 194 .then((response) {
195 if (_isErrorResponse(response)) { 195 if (_isErrorResponse(response)) {
196 throw _exceptionOrErrorFromResponse(response, "Rename failed"); 196 throw _exceptionOrErrorFromResponse(response, "Rename failed");
197 } 197 }
198 return new Directory(newPath); 198 return new Directory(newPath);
199 }); 199 });
200 } 200 }
201 201
202 Directory renameSync(String newPath) { 202 Directory renameSync(String newPath) {
203 if (newPath is !String) { 203 if (newPath is !String) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 _AsyncDirectoryLister(this.path, this.recursive, this.followLinks) { 274 _AsyncDirectoryLister(this.path, this.recursive, this.followLinks) {
275 controller = new StreamController(onListen: onListen, 275 controller = new StreamController(onListen: onListen,
276 onResume: onResume, 276 onResume: onResume,
277 onCancel: onCancel, 277 onCancel: onCancel,
278 sync: true); 278 sync: true);
279 } 279 }
280 280
281 Stream get stream => controller.stream; 281 Stream get stream => controller.stream;
282 282
283 void onListen() { 283 void onListen() {
284 _IOService.dispatch(_DIRECTORY_LIST_START, [path, recursive, followLinks]) 284 _IOService._dispatch(_DIRECTORY_LIST_START, [path, recursive, followLinks])
285 .then((response) { 285 .then((response) {
286 if (response is int) { 286 if (response is int) {
287 id = response; 287 id = response;
288 next(); 288 next();
289 } else if (response is Error) { 289 } else if (response is Error) {
290 controller.addError(response); 290 controller.addError(response);
291 close(); 291 close();
292 } else { 292 } else {
293 error(response); 293 error(response);
294 close(); 294 close();
(...skipping 17 matching lines...) Expand all
312 312
313 void next() { 313 void next() {
314 if (canceled) { 314 if (canceled) {
315 close(); 315 close();
316 return; 316 return;
317 } 317 }
318 if (id == null) return; 318 if (id == null) return;
319 if (controller.isPaused) return; 319 if (controller.isPaused) return;
320 if (nextRunning) return; 320 if (nextRunning) return;
321 nextRunning = true; 321 nextRunning = true;
322 _IOService.dispatch(_DIRECTORY_LIST_NEXT, [id]).then((result) { 322 _IOService._dispatch(_DIRECTORY_LIST_NEXT, [id]).then((result) {
323 nextRunning = false; 323 nextRunning = false;
324 if (result is List) { 324 if (result is List) {
325 next(); 325 next();
326 assert(result.length % 2 == 0); 326 assert(result.length % 2 == 0);
327 for (int i = 0; i < result.length; i++) { 327 for (int i = 0; i < result.length; i++) {
328 assert(i % 2 == 0); 328 assert(i % 2 == 0);
329 switch (result[i++]) { 329 switch (result[i++]) {
330 case LIST_FILE: 330 case LIST_FILE:
331 controller.add(new File(result[i])); 331 controller.add(new File(result[i]));
332 break; 332 break;
(...skipping 19 matching lines...) Expand all
352 352
353 void close() { 353 void close() {
354 if (closed) return; 354 if (closed) return;
355 if (nextRunning) return; 355 if (nextRunning) return;
356 void cleanup() { 356 void cleanup() {
357 controller.close(); 357 controller.close();
358 closeCompleter.complete(); 358 closeCompleter.complete();
359 } 359 }
360 closed = true; 360 closed = true;
361 if (id != null) { 361 if (id != null) {
362 _IOService.dispatch(_DIRECTORY_LIST_STOP, [id]).whenComplete(cleanup); 362 _IOService._dispatch(_DIRECTORY_LIST_STOP, [id]).whenComplete(cleanup);
363 } else { 363 } else {
364 cleanup(); 364 cleanup();
365 } 365 }
366 } 366 }
367 367
368 void error(message) { 368 void error(message) {
369 var errorType = 369 var errorType =
370 message[RESPONSE_ERROR][_ERROR_RESPONSE_ERROR_TYPE]; 370 message[RESPONSE_ERROR][_ERROR_RESPONSE_ERROR_TYPE];
371 if (errorType == _ILLEGAL_ARGUMENT_RESPONSE) { 371 if (errorType == _ILLEGAL_ARGUMENT_RESPONSE) {
372 controller.addError(new ArgumentError()); 372 controller.addError(new ArgumentError());
373 } else if (errorType == _OSERROR_RESPONSE) { 373 } else if (errorType == _OSERROR_RESPONSE) {
374 var responseError = message[RESPONSE_ERROR]; 374 var responseError = message[RESPONSE_ERROR];
375 var err = new OSError( 375 var err = new OSError(
376 responseError[_OSERROR_RESPONSE_MESSAGE], 376 responseError[_OSERROR_RESPONSE_MESSAGE],
377 responseError[_OSERROR_RESPONSE_ERROR_CODE]); 377 responseError[_OSERROR_RESPONSE_ERROR_CODE]);
378 var errorPath = message[RESPONSE_PATH]; 378 var errorPath = message[RESPONSE_PATH];
379 if (errorPath == null) errorPath = path; 379 if (errorPath == null) errorPath = path;
380 controller.addError( 380 controller.addError(
381 new FileSystemException("Directory listing failed", 381 new FileSystemException("Directory listing failed",
382 errorPath, 382 errorPath,
383 err)); 383 err));
384 } else { 384 } else {
385 controller.addError( 385 controller.addError(
386 new FileSystemException("Internal error")); 386 new FileSystemException("Internal error"));
387 } 387 }
388 } 388 }
389 } 389 }
OLDNEW
« no previous file with comments | « sdk/lib/io/data_transformer.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698