| 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 | 5 |
| 6 /** | 6 /** |
| 7 * FileMode describes the modes in which a file can be opened. | 7 * FileMode describes the modes in which a file can be opened. |
| 8 */ | 8 */ |
| 9 class FileMode { | 9 class FileMode { |
| 10 static final READ = const FileMode(0); | 10 static final READ = const FileMode(0); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 * | 169 * |
| 170 * See [openOutputStream] for information on the [:mode:] argument. | 170 * See [openOutputStream] for information on the [:mode:] argument. |
| 171 * | 171 * |
| 172 * Even though this call to open the output stream is synchronous | 172 * Even though this call to open the output stream is synchronous |
| 173 * the output stream itself is asynchronous as is the case for all | 173 * the output stream itself is asynchronous as is the case for all |
| 174 * output streams. | 174 * output streams. |
| 175 */ | 175 */ |
| 176 OutputStream openOutputStreamSync([FileMode mode]); | 176 OutputStream openOutputStreamSync([FileMode mode]); |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * Read the entire file contents as a list of bytes. When the |
| 180 * operation completes the [readAsBytesHandler] is called. |
| 181 * The [errorHandler] is called if the operation fails. |
| 182 */ |
| 183 void readAsBytes(); |
| 184 |
| 185 /** |
| 186 * Synchronously read the entire file contents as a list of bytes. |
| 187 */ |
| 188 List<int> readAsBytesSync(); |
| 189 |
| 190 /** |
| 191 * Read the entire file contents as text using the give [encoding] |
| 192 * ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the encoding is |
| 193 * 'UTF-8'. |
| 194 * |
| 195 * When the operation completes the [readAsTextHandler] is called |
| 196 * with the resulting string. The [errorHandler] is called if the |
| 197 * operation fails. |
| 198 */ |
| 199 void readAsText([String encoding]); |
| 200 |
| 201 /** |
| 202 * Synchronously read the entire file contents as text using the |
| 203 * give [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the |
| 204 * encoding is 'UTF-8'. |
| 205 */ |
| 206 String readAsTextSync([String encoding]); |
| 207 |
| 208 /** |
| 209 * Read the entire file contents as lines of text using the give |
| 210 * [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the |
| 211 * encoding is 'UTF-8'. |
| 212 * |
| 213 * When the operation completes the [readAsLinesHandler] is called |
| 214 * with the resulting string. The [errorHandler] is called if the |
| 215 * operation fails. |
| 216 */ |
| 217 void readAsLines(); |
| 218 |
| 219 /** |
| 220 * Synchronously read the entire file contents as lines of text |
| 221 * using the give [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By |
| 222 * default the encoding is 'UTF-8'. |
| 223 */ |
| 224 List<String> readAsLinesSync([String encoding]); |
| 225 |
| 226 /** |
| 179 * Get the name of the file. | 227 * Get the name of the file. |
| 180 */ | 228 */ |
| 181 String get name(); | 229 String get name(); |
| 182 | 230 |
| 183 /** | 231 /** |
| 184 * Sets the handler that gets called when an [exists] operation | 232 * Sets the handler that gets called when an [exists] operation |
| 185 * completes. | 233 * completes. |
| 186 */ | 234 */ |
| 187 void set existsHandler(void handler(bool exists)); | 235 void set existsHandler(void handler(bool exists)); |
| 188 | 236 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 216 */ | 264 */ |
| 217 void set inputStreamHandler(void handler(InputStream stream)); | 265 void set inputStreamHandler(void handler(InputStream stream)); |
| 218 | 266 |
| 219 /** | 267 /** |
| 220 * Sets the handler that gets called when an [openOutputStream] | 268 * Sets the handler that gets called when an [openOutputStream] |
| 221 * operation completes. | 269 * operation completes. |
| 222 */ | 270 */ |
| 223 void set outputStreamHandler(void handler(OutputStream stream)); | 271 void set outputStreamHandler(void handler(OutputStream stream)); |
| 224 | 272 |
| 225 /** | 273 /** |
| 274 * Set the handler that gets called when a [readAsBytes] operation |
| 275 * completes. |
| 276 */ |
| 277 void set readAsBytesHandler(void handler(List<int> bytes)); |
| 278 |
| 279 /** |
| 280 * Set the handler that gets called when a [readAsText] operation |
| 281 * completes. |
| 282 */ |
| 283 void set readAsTextHandler(void handler(String text)); |
| 284 |
| 285 /** |
| 286 * Set the handler that gets called when a [readAsLines] operation |
| 287 * completes. |
| 288 */ |
| 289 void set readAsLinesHandler(void handler(List<String> lines)); |
| 290 |
| 291 /** |
| 226 * Sets the handler that gets called when a [fullPath] operation | 292 * Sets the handler that gets called when a [fullPath] operation |
| 227 * completes. | 293 * completes. |
| 228 */ | 294 */ |
| 229 void set fullPathHandler(void handler(String path)); | 295 void set fullPathHandler(void handler(String path)); |
| 230 | 296 |
| 231 /** | 297 /** |
| 232 * Sets the handler that gets called when errors occur during | 298 * Sets the handler that gets called when errors occur during |
| 233 * operations on this file. | 299 * operations on this file. |
| 234 */ | 300 */ |
| 235 void set errorHandler(void handler(String error)); | 301 void set errorHandler(void handler(String error)); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 */ | 504 */ |
| 439 void set errorHandler(void handler(String error)); | 505 void set errorHandler(void handler(String error)); |
| 440 } | 506 } |
| 441 | 507 |
| 442 | 508 |
| 443 class FileIOException implements Exception { | 509 class FileIOException implements Exception { |
| 444 const FileIOException([String this.message = ""]); | 510 const FileIOException([String this.message = ""]); |
| 445 String toString() => "FileIOException: $message"; | 511 String toString() => "FileIOException: $message"; |
| 446 final String message; | 512 final String message; |
| 447 } | 513 } |
| OLD | NEW |