Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 return new FileIOException("File closed"); | 486 return new FileIOException("File closed"); |
| 487 default: | 487 default: |
| 488 return new Exception("Unknown error"); | 488 return new Exception("Unknown error"); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 // Class for encapsulating the native implementation of files. | 493 // Class for encapsulating the native implementation of files. |
| 494 class _File extends _FileBase implements File { | 494 class _File extends _FileBase implements File { |
| 495 // Constructor for file. | 495 // Constructor for file. |
| 496 _File(String this._name); | 496 _File(String this._name) { |
| 497 if (_name is! String) { | |
| 498 throw new ArgumentError('${NoSuchMethodError.safeToString(_name)} ' | |
|
Ivan Posva
2012/10/02 00:19:38
Peter can you explain why you are using NoSuchMeth
ahe
2012/10/02 04:49:24
It makes sense to use safeToString here because th
Ivan Posva
2012/10/02 05:19:11
It just feels very strange to be calling some rand
ahe
2012/10/02 05:39:47
Agreed, I would like to find a better place for th
ahe
2012/10/02 07:47:11
Filed http://dartbug.com/5596.
| |
| 499 'is not a String'); | |
| 500 } | |
| 501 } | |
| 497 | 502 |
| 498 // Constructor from Path for file. | 503 // Constructor from Path for file. |
| 499 _File.fromPath(Path path) : this(path.toNativePath()); | 504 _File.fromPath(Path path) : this(path.toNativePath()); |
| 500 | 505 |
| 501 Future<bool> exists() { | 506 Future<bool> exists() { |
| 502 _ensureFileService(); | 507 _ensureFileService(); |
| 503 List request = new List(2); | 508 List request = new List(2); |
| 504 request[0] = _FileUtils.EXISTS_REQUEST; | 509 request[0] = _FileUtils.EXISTS_REQUEST; |
| 505 request[1] = _name; | 510 request[1] = _name; |
| 506 return _fileService.call(request).transform((response) { | 511 return _fileService.call(request).transform((response) { |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 new FileIOException("File closed '$_name'")); | 1170 new FileIOException("File closed '$_name'")); |
| 1166 }); | 1171 }); |
| 1167 return completer.future; | 1172 return completer.future; |
| 1168 } | 1173 } |
| 1169 | 1174 |
| 1170 final String _name; | 1175 final String _name; |
| 1171 int _id; | 1176 int _id; |
| 1172 | 1177 |
| 1173 SendPort _fileService; | 1178 SendPort _fileService; |
| 1174 } | 1179 } |
| OLD | NEW |