| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 final String path; | 226 final String path; |
| 227 | 227 |
| 228 // Constructor for file. | 228 // Constructor for file. |
| 229 _File(String this.path) { | 229 _File(String this.path) { |
| 230 if (path is! String) { | 230 if (path is! String) { |
| 231 throw new ArgumentError('${Error.safeToString(path)} ' | 231 throw new ArgumentError('${Error.safeToString(path)} ' |
| 232 'is not a String'); | 232 'is not a String'); |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Constructor for file from a URI. |
| 237 factory _File.fromUri(Uri uri) => new _File(uri.toFilePath()); |
| 238 |
| 236 Future<bool> exists() { | 239 Future<bool> exists() { |
| 237 return _IOService.dispatch(_FILE_EXISTS, [path]).then((response) { | 240 return _IOService.dispatch(_FILE_EXISTS, [path]).then((response) { |
| 238 if (_isErrorResponse(response)) { | 241 if (_isErrorResponse(response)) { |
| 239 throw _exceptionFromResponse(response, "Cannot check existence", path); | 242 throw _exceptionFromResponse(response, "Cannot check existence", path); |
| 240 } | 243 } |
| 241 return response; | 244 return response; |
| 242 }); | 245 }); |
| 243 } | 246 } |
| 244 | 247 |
| 245 external static _exists(String path); | 248 external static _exists(String path); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 | 882 |
| 880 void _checkAvailable() { | 883 void _checkAvailable() { |
| 881 if (_asyncDispatched) { | 884 if (_asyncDispatched) { |
| 882 throw new FileSystemException("An async operation is currently pending", p
ath); | 885 throw new FileSystemException("An async operation is currently pending", p
ath); |
| 883 } | 886 } |
| 884 if (closed) { | 887 if (closed) { |
| 885 throw new FileSystemException("File closed", path); | 888 throw new FileSystemException("File closed", path); |
| 886 } | 889 } |
| 887 } | 890 } |
| 888 } | 891 } |
| OLD | NEW |