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/file_impl.dart

Issue 23889008: Move delete/deleteSync up to FileSystemEntity, with a shared documentation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Style fixes. 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/io/file.dart ('k') | sdk/lib/io/file_system_entity.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Read the file in blocks of size 64k. 7 // Read the file in blocks of size 64k.
8 const int _BLOCK_SIZE = 64 * 1024; 8 const int _BLOCK_SIZE = 64 * 1024;
9 9
10 10
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 external static _createLink(String path, String target); 289 external static _createLink(String path, String target);
290 290
291 external static _linkTarget(String path); 291 external static _linkTarget(String path);
292 292
293 void createSync() { 293 void createSync() {
294 var result = _create(path); 294 var result = _create(path);
295 throwIfError(result, "Cannot create file", path); 295 throwIfError(result, "Cannot create file", path);
296 } 296 }
297 297
298 Future<File> delete() { 298 Future<File> _delete({bool recursive: false}) {
299 if (recursive) {
300 return new Directory(path).delete(recursive: true).then((_) => this);
301 }
299 _ensureFileService(); 302 _ensureFileService();
300 List request = new List(2); 303 List request = new List(2);
301 request[0] = _DELETE_REQUEST; 304 request[0] = _DELETE_REQUEST;
302 request[1] = path; 305 request[1] = path;
303 return _fileService.call(request).then((response) { 306 return _fileService.call(request).then((response) {
304 if (_isErrorResponse(response)) { 307 if (_isErrorResponse(response)) {
305 throw _exceptionFromResponse(response, "Cannot delete file", path); 308 throw _exceptionFromResponse(response, "Cannot delete file", path);
306 } 309 }
307 return this; 310 return this;
308 }); 311 });
309 } 312 }
310 313
311 external static _delete(String path); 314 external static _deleteNative(String path);
312 315
313 external static _deleteLink(String path); 316 external static _deleteLinkNative(String path);
314 317
315 void deleteSync() { 318 void _deleteSync({bool recursive: false}) {
316 var result = _delete(path); 319 if (recursive) {
320 return new Directory(path).deleteSync(recursive: true);
321 }
322 var result = _deleteNative(path);
317 throwIfError(result, "Cannot delete file", path); 323 throwIfError(result, "Cannot delete file", path);
318 } 324 }
319 325
320 Future<File> rename(String newPath) { 326 Future<File> rename(String newPath) {
321 _ensureFileService(); 327 _ensureFileService();
322 List request = new List(3); 328 List request = new List(3);
323 request[0] = _RENAME_REQUEST; 329 request[0] = _RENAME_REQUEST;
324 request[1] = path; 330 request[1] = path;
325 request[2] = newPath; 331 request[2] = newPath;
326 return _fileService.call(request).then((response) { 332 return _fileService.call(request).then((response) {
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 void _checkNotClosed() { 983 void _checkNotClosed() {
978 if (closed) { 984 if (closed) {
979 throw new FileException("File closed", path); 985 throw new FileException("File closed", path);
980 } 986 }
981 } 987 }
982 988
983 Future _closedException() { 989 Future _closedException() {
984 return new Future.error(new FileException("File closed", path)); 990 return new Future.error(new FileException("File closed", path));
985 } 991 }
986 } 992 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698