| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void fullPath(); | 122 void fullPath(); |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Synchronously get the canonical full path corresponding to the file name. | 125 * Synchronously get the canonical full path corresponding to the file name. |
| 126 */ | 126 */ |
| 127 String fullPathSync(); | 127 String fullPathSync(); |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * Create a new independent input stream for the file. The file | 130 * Create a new independent input stream for the file. The file |
| 131 * input stream must be closed when no longer used to free up system | 131 * input stream must be closed when no longer used to free up system |
| 132 * resources. The [inputStreamHandler] is called with the result | 132 * resources. |
| 133 * when the openInputStream operation completes. | |
| 134 */ | 133 */ |
| 135 void openInputStream(); | 134 InputStream openInputStream(); |
| 136 | |
| 137 /** | |
| 138 * Synchronously create a new independent input stream for the | |
| 139 * file. The file input stream must be closed when no longer used to | |
| 140 * free up system resources. | |
| 141 * | |
| 142 * Even though this call to open the input stream is synchronous the | |
| 143 * input stream itself is asynchronous as is the case for all input | |
| 144 * streams. | |
| 145 */ | |
| 146 InputStream openInputStreamSync(); | |
| 147 | 135 |
| 148 /** | 136 /** |
| 149 * Creates a new independent output stream for the file. The file | 137 * Creates a new independent output stream for the file. The file |
| 150 * output stream must be closed when no longer used to free up | 138 * output stream must be closed when no longer used to free up |
| 151 * system resources. The [outputStreamHandler] is called with the result | 139 * system resources. |
| 152 * when the openOutputStream operation completes. | |
| 153 * | 140 * |
| 154 * An output stream can be opened in two modes: | 141 * An output stream can be opened in two modes: |
| 155 * | 142 * |
| 156 * FileMode.WRITE: create the stream and truncate the underlying | 143 * FileMode.WRITE: create the stream and truncate the underlying |
| 157 * file to length zero. | 144 * file to length zero. |
| 158 * | 145 * |
| 159 * FileMode.APPEND: create the stream and set the position to the end of | 146 * FileMode.APPEND: create the stream and set the position to the end of |
| 160 * the underlying file. | 147 * the underlying file. |
| 161 * | 148 * |
| 162 * By default the mode is FileMode.WRITE. | 149 * By default the mode is FileMode.WRITE. |
| 163 */ | 150 */ |
| 164 void openOutputStream([FileMode mode]); | 151 OutputStream openOutputStream([FileMode mode]); |
| 165 | |
| 166 /** | |
| 167 * Synchronously creates a new independent output stream for the | |
| 168 * file. The file output stream must be closed when no longer used | |
| 169 * to free up system resources. | |
| 170 * | |
| 171 * See [openOutputStream] for information on the [:mode:] argument. | |
| 172 * | |
| 173 * Even though this call to open the output stream is synchronous | |
| 174 * the output stream itself is asynchronous as is the case for all | |
| 175 * output streams. | |
| 176 */ | |
| 177 OutputStream openOutputStreamSync([FileMode mode]); | |
| 178 | 152 |
| 179 /** | 153 /** |
| 180 * Read the entire file contents as a list of bytes. When the | 154 * Read the entire file contents as a list of bytes. When the |
| 181 * operation completes the [readAsBytesHandler] is called. | 155 * operation completes the [readAsBytesHandler] is called. |
| 182 * The [errorHandler] is called if the operation fails. | 156 * The [errorHandler] is called if the operation fails. |
| 183 */ | 157 */ |
| 184 void readAsBytes(); | 158 void readAsBytes(); |
| 185 | 159 |
| 186 /** | 160 /** |
| 187 * Synchronously read the entire file contents as a list of bytes. | 161 * Synchronously read the entire file contents as a list of bytes. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 */ | 227 */ |
| 254 void set directoryHandler(void handler(Directory directory)); | 228 void set directoryHandler(void handler(Directory directory)); |
| 255 | 229 |
| 256 /** | 230 /** |
| 257 * Sets the handler that gets called when an [open] operation | 231 * Sets the handler that gets called when an [open] operation |
| 258 * completes. | 232 * completes. |
| 259 */ | 233 */ |
| 260 void set openHandler(void handler(RandomAccessFile openedFile)); | 234 void set openHandler(void handler(RandomAccessFile openedFile)); |
| 261 | 235 |
| 262 /** | 236 /** |
| 263 * Sets the handler that gets called when an [openInputStream] | |
| 264 * operation completes. | |
| 265 */ | |
| 266 void set inputStreamHandler(void handler(InputStream stream)); | |
| 267 | |
| 268 /** | |
| 269 * Sets the handler that gets called when an [openOutputStream] | |
| 270 * operation completes. | |
| 271 */ | |
| 272 void set outputStreamHandler(void handler(OutputStream stream)); | |
| 273 | |
| 274 /** | |
| 275 * Set the handler that gets called when a [readAsBytes] operation | 237 * Set the handler that gets called when a [readAsBytes] operation |
| 276 * completes. | 238 * completes. |
| 277 */ | 239 */ |
| 278 void set readAsBytesHandler(void handler(List<int> bytes)); | 240 void set readAsBytesHandler(void handler(List<int> bytes)); |
| 279 | 241 |
| 280 /** | 242 /** |
| 281 * Set the handler that gets called when a [readAsText] operation | 243 * Set the handler that gets called when a [readAsText] operation |
| 282 * completes. | 244 * completes. |
| 283 */ | 245 */ |
| 284 void set readAsTextHandler(void handler(String text)); | 246 void set readAsTextHandler(void handler(String text)); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 */ | 467 */ |
| 506 void set errorHandler(void handler(String error)); | 468 void set errorHandler(void handler(String error)); |
| 507 } | 469 } |
| 508 | 470 |
| 509 | 471 |
| 510 class FileIOException implements Exception { | 472 class FileIOException implements Exception { |
| 511 const FileIOException([String this.message = ""]); | 473 const FileIOException([String this.message = ""]); |
| 512 String toString() => "FileIOException: $message"; | 474 String toString() => "FileIOException: $message"; |
| 513 final String message; | 475 final String message; |
| 514 } | 476 } |
| OLD | NEW |