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

Side by Side Diff: runtime/bin/file_impl.dart

Issue 10639004: Add .fromPath constructors to File and Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 6 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 | « runtime/bin/file.dart ('k') | tests/standalone/io/directory_test.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 class _FileInputStream extends _BaseDataInputStream implements InputStream { 5 class _FileInputStream extends _BaseDataInputStream implements InputStream {
6 _FileInputStream(String name) 6 _FileInputStream(String name)
7 : _data = const [], 7 : _data = const [],
8 _position = 0, 8 _position = 0,
9 _filePosition = 0 { 9 _filePosition = 0 {
10 var file = new File(name); 10 var file = new File(name);
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 return new Exception("Unknown error"); 485 return new Exception("Unknown error");
486 } 486 }
487 } 487 }
488 } 488 }
489 489
490 // Class for encapsulating the native implementation of files. 490 // Class for encapsulating the native implementation of files.
491 class _File extends _FileBase implements File { 491 class _File extends _FileBase implements File {
492 // Constructor for file. 492 // Constructor for file.
493 _File(String this._name); 493 _File(String this._name);
494 494
495 // Constructor from Path for file.
496 _File.fromPath(Path path) : this(path.toNativePath());
497
495 Future<bool> exists() { 498 Future<bool> exists() {
496 _ensureFileService(); 499 _ensureFileService();
497 List request = new List(2); 500 List request = new List(2);
498 request[0] = _FileUtils.EXISTS_REQUEST; 501 request[0] = _FileUtils.EXISTS_REQUEST;
499 request[1] = _name; 502 request[1] = _name;
500 return _fileService.call(request).transform((response) { 503 return _fileService.call(request).transform((response) {
501 if (_isErrorResponse(response)) { 504 if (_isErrorResponse(response)) {
502 throw _exceptionFromResponse(response, "Cannot open file '$_name'"); 505 throw _exceptionFromResponse(response, "Cannot open file '$_name'");
503 } 506 }
504 return response; 507 return response;
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 new FileIOException("File closed '$_name'")); 1158 new FileIOException("File closed '$_name'"));
1156 }); 1159 });
1157 return completer.future; 1160 return completer.future;
1158 } 1161 }
1159 1162
1160 final String _name; 1163 final String _name;
1161 int _id; 1164 int _id;
1162 1165
1163 SendPort _fileService; 1166 SendPort _fileService;
1164 } 1167 }
OLDNEW
« no previous file with comments | « runtime/bin/file.dart ('k') | tests/standalone/io/directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698