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

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

Issue 23054008: Remove the Path class from dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed first round of review comments Created 7 years, 4 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 SendPort _fileService; 239 SendPort _fileService;
240 240
241 // Constructor for file. 241 // Constructor for file.
242 _File(String this.path) { 242 _File(String this.path) {
243 if (path is! String) { 243 if (path is! String) {
244 throw new ArgumentError('${Error.safeToString(path)} ' 244 throw new ArgumentError('${Error.safeToString(path)} '
245 'is not a String'); 245 'is not a String');
246 } 246 }
247 } 247 }
248 248
249 // Constructor from Path for file.
250 _File.fromPath(Path path) : this(path.toNativePath());
251
252 Future<bool> exists() { 249 Future<bool> exists() {
253 _ensureFileService(); 250 _ensureFileService();
254 List request = new List(2); 251 List request = new List(2);
255 request[0] = _EXISTS_REQUEST; 252 request[0] = _EXISTS_REQUEST;
256 request[1] = path; 253 request[1] = path;
257 return _fileService.call(request).then((response) { 254 return _fileService.call(request).then((response) {
258 if (_isErrorResponse(response)) { 255 if (_isErrorResponse(response)) {
259 throw _exceptionFromResponse(response, "Cannot check existence", path); 256 throw _exceptionFromResponse(response, "Cannot check existence", path);
260 } 257 }
261 return response; 258 return response;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 336
340 external static _renameLink(String oldPath, String newPath); 337 external static _renameLink(String oldPath, String newPath);
341 338
342 File renameSync(String newPath) { 339 File renameSync(String newPath) {
343 var result = _rename(path, newPath); 340 var result = _rename(path, newPath);
344 throwIfError(result, "Cannot rename file to '$newPath'", path); 341 throwIfError(result, "Cannot rename file to '$newPath'", path);
345 return new File(newPath); 342 return new File(newPath);
346 } 343 }
347 344
348 Directory get directory { 345 Directory get directory {
349 Path path = new Path(this.path).directoryPath; 346 _Path path = new _Path(this.path).directoryPath;
350 return new Directory.fromPath(path); 347 return new Directory(path.toNativePath());
351 } 348 }
352 349
353 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) { 350 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) {
354 _ensureFileService(); 351 _ensureFileService();
355 if (mode != FileMode.READ && 352 if (mode != FileMode.READ &&
356 mode != FileMode.WRITE && 353 mode != FileMode.WRITE &&
357 mode != FileMode.APPEND) { 354 mode != FileMode.APPEND) {
358 return new Future.error(new ArgumentError()); 355 return new Future.error(new ArgumentError());
359 } 356 }
360 List request = new List(3); 357 List request = new List(3);
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 void _checkNotClosed() { 977 void _checkNotClosed() {
981 if (closed) { 978 if (closed) {
982 throw new FileException("File closed", path); 979 throw new FileException("File closed", path);
983 } 980 }
984 } 981 }
985 982
986 Future _closedException() { 983 Future _closedException() {
987 return new Future.error(new FileException("File closed", path)); 984 return new Future.error(new FileException("File closed", path));
988 } 985 }
989 } 986 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698