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 | 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 11 matching lines...) Expand all Loading... | |
| 22 * streams using [openInputStream] and [openOutputStream] or open the | 22 * streams using [openInputStream] and [openOutputStream] or open the |
| 23 * file for random access operations using [open]. | 23 * file for random access operations using [open]. |
| 24 */ | 24 */ |
| 25 interface File default _File { | 25 interface File default _File { |
| 26 /** | 26 /** |
| 27 * Create a File object. | 27 * Create a File object. |
| 28 */ | 28 */ |
| 29 File(String name); | 29 File(String name); |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Check if the file exists. The [existsHandler] is called with the | 32 * Check if the file exists. [onExists] is called with the result |
| 33 * result when the operation completes. | 33 * when the operation completes. |
| 34 */ | 34 */ |
| 35 void exists(); | 35 void exists(); |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Synchronously check if the file exists. | 38 * Synchronously check if the file exists. |
| 39 */ | 39 */ |
| 40 bool existsSync(); | 40 bool existsSync(); |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Create the file. The [createHandler] is called when the file has | 43 * Create the file. [onCreate] is called when the file has been |
| 44 * been created. The [errorHandler] is called if the file cannot be | 44 * created. [onError] is called if the file cannot be |
| 45 * created. Existing files are left untouched by create. Calling | 45 * created. Existing files are left untouched by create. Calling |
| 46 * create on an existing file might fail if there are restrictive | 46 * create on an existing file might fail if there are restrictive |
| 47 * permissions on the file. | 47 * permissions on the file. |
| 48 */ | 48 */ |
| 49 void create(); | 49 void create(); |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Synchronously create the file. Existing files are left untouched | 52 * Synchronously create the file. Existing files are left untouched |
| 53 * by create. Calling create on an existing file might fail if there | 53 * by create. Calling create on an existing file might fail if there |
| 54 * are restrictive permissions on the file. | 54 * are restrictive permissions on the file. |
| 55 */ | 55 */ |
| 56 void createSync(); | 56 void createSync(); |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Delete the file. The [deleteHandler] is called when the file has | 59 * Delete the file. [onDelete] is called when the file has been |
| 60 * been successfully deleted. The [errorHandler] is called if the | 60 * successfully deleted. [onError] is called if the file cannot be |
| 61 * file cannot be deleted. | 61 * deleted. |
| 62 */ | 62 */ |
| 63 void delete(); | 63 void delete(); |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Synchronously delete the file. | 66 * Synchronously delete the file. |
| 67 */ | 67 */ |
| 68 void deleteSync(); | 68 void deleteSync(); |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Get a Directory object for the directory containing this file. If | 71 * Get a Directory object for the directory containing this file. If |
| 72 * the file does not exist the [errorHandler] is called. When the | 72 * the file does not exist [onError] is called. When the operation |
| 73 * operation completes the [directoryHandler] is called with the | 73 * completes [onDirectory] is called with the result. |
| 74 * result. | |
| 75 */ | 74 */ |
| 76 void directory(); | 75 void directory(); |
| 77 | 76 |
| 78 /** | 77 /** |
| 79 * Synchronously get a Directory object for the directory containing | 78 * Synchronously get a Directory object for the directory containing |
| 80 * this file. | 79 * this file. |
| 81 */ | 80 */ |
| 82 Directory directorySync(); | 81 Directory directorySync(); |
| 83 | 82 |
| 84 /** | 83 /** |
| 85 * Open the file for random access operations. When the file is | 84 * Open the file for random access operations. When the file is |
| 86 * opened the [openHandler] is called with the resulting | 85 * opened [onOpen] is called with the resulting |
| 87 * RandomAccessFile. RandomAccessFiles must be closed using the | 86 * RandomAccessFile. RandomAccessFiles must be closed using the |
| 88 * [close] method. If the file cannot be opened the [errorHandler] | 87 * [close] method. If the file cannot be opened [onError] is called. |
| 89 * is called. | |
| 90 * | 88 * |
| 91 * Files can be opened in three modes: | 89 * Files can be opened in three modes: |
| 92 * | 90 * |
| 93 * FileMode.READ: open the file for reading. If the file does not | 91 * FileMode.READ: open the file for reading. If the file does not |
| 94 * exist the [errorHandler] is called. | 92 * exist [onError] is called. |
| 95 * | 93 * |
| 96 * FileMode.WRITE: open the file for both reading and writing and | 94 * FileMode.WRITE: open the file for both reading and writing and |
| 97 * truncate the file to length zero. If the file does not exist the | 95 * truncate the file to length zero. If the file does not exist the |
| 98 * file is created. | 96 * file is created. |
| 99 * | 97 * |
| 100 * FileMode.APPEND: same as FileMode.WRITE except that the file is | 98 * FileMode.APPEND: same as FileMode.WRITE except that the file is |
| 101 * not truncated. | 99 * not truncated. |
| 102 * | 100 * |
| 103 * By default mode is FileMode.READ. | 101 * By default mode is FileMode.READ. |
| 104 */ | 102 */ |
| 105 void open([FileMode mode]); | 103 void open([FileMode mode]); |
| 106 | 104 |
| 107 /** | 105 /** |
| 108 * Synchronously open the file for random access operations. The | 106 * Synchronously open the file for random access operations. The |
| 109 * result is a RandomAccessFile on which random access operations | 107 * result is a RandomAccessFile on which random access operations |
| 110 * can be performed. Opened RandomAccessFiles must be closed using | 108 * can be performed. Opened RandomAccessFiles must be closed using |
| 111 * the [close] method. | 109 * the [close] method. |
| 112 * | 110 * |
| 113 * See [open] for information on the [:mode:] argument. | 111 * See [open] for information on the [:mode:] argument. |
| 114 */ | 112 */ |
| 115 RandomAccessFile openSync([FileMode mode]); | 113 RandomAccessFile openSync([FileMode mode]); |
| 116 | 114 |
| 117 /** | 115 /** |
| 118 * Get the canonical full path corresponding to the file name. The | 116 * Get the canonical full path corresponding to the file name. |
| 119 * [fullPathHandler] is called with the result when the fullPath | 117 * [onFullPath] is called with the result when the fullPath |
| 120 * operation completes. | 118 * operation completes. |
| 121 */ | 119 */ |
| 122 void fullPath(); | 120 void fullPath(); |
| 123 | 121 |
| 124 /** | 122 /** |
| 125 * Synchronously get the canonical full path corresponding to the file name. | 123 * Synchronously get the canonical full path corresponding to the file name. |
| 126 */ | 124 */ |
| 127 String fullPathSync(); | 125 String fullPathSync(); |
| 128 | 126 |
| 129 /** | 127 /** |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 145 * | 143 * |
| 146 * FileMode.APPEND: create the stream and set the position to the end of | 144 * FileMode.APPEND: create the stream and set the position to the end of |
| 147 * the underlying file. | 145 * the underlying file. |
| 148 * | 146 * |
| 149 * By default the mode is FileMode.WRITE. | 147 * By default the mode is FileMode.WRITE. |
| 150 */ | 148 */ |
| 151 OutputStream openOutputStream([FileMode mode]); | 149 OutputStream openOutputStream([FileMode mode]); |
| 152 | 150 |
| 153 /** | 151 /** |
| 154 * Read the entire file contents as a list of bytes. When the | 152 * Read the entire file contents as a list of bytes. When the |
| 155 * operation completes the [readAsBytesHandler] is called. | 153 * operation completes [onReadAsBytes] is called. [onError] is |
| 156 * The [errorHandler] is called if the operation fails. | 154 * called if the operation fails. |
| 157 */ | 155 */ |
| 158 void readAsBytes(); | 156 void readAsBytes(); |
| 159 | 157 |
| 160 /** | 158 /** |
| 161 * Synchronously read the entire file contents as a list of bytes. | 159 * Synchronously read the entire file contents as a list of bytes. |
| 162 */ | 160 */ |
| 163 List<int> readAsBytesSync(); | 161 List<int> readAsBytesSync(); |
| 164 | 162 |
| 165 /** | 163 /** |
| 166 * Read the entire file contents as text using the given [encoding] | 164 * Read the entire file contents as text using the given [encoding] |
| 167 * ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the encoding is | 165 * ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the encoding is |
| 168 * 'UTF-8'. | 166 * 'UTF-8'. |
| 169 * | 167 * |
| 170 * When the operation completes the [readAsTextHandler] is called | 168 * When the operation completes [onReadAsText] is called with the |
| 171 * with the resulting string. The [errorHandler] is called if the | 169 * resulting string. [onError] is called if the operation fails. |
| 172 * operation fails. | |
| 173 */ | 170 */ |
| 174 void readAsText([String encoding]); | 171 void readAsText([String encoding]); |
| 175 | 172 |
| 176 /** | 173 /** |
| 177 * Synchronously read the entire file contents as text using the | 174 * Synchronously read the entire file contents as text using the |
| 178 * given [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the | 175 * given [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the |
| 179 * encoding is 'UTF-8'. | 176 * encoding is 'UTF-8'. |
| 180 */ | 177 */ |
| 181 String readAsTextSync([String encoding]); | 178 String readAsTextSync([String encoding]); |
| 182 | 179 |
| 183 /** | 180 /** |
| 184 * Read the entire file contents as lines of text using the give | 181 * Read the entire file contents as lines of text using the give |
| 185 * [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the | 182 * [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By default the |
| 186 * encoding is 'UTF-8'. | 183 * encoding is 'UTF-8'. |
| 187 * | 184 * |
| 188 * When the operation completes the [readAsLinesHandler] is called | 185 * When the operation completes [onReadAsLines] is called with the |
| 189 * with the resulting string. The [errorHandler] is called if the | 186 * resulting string. [onError] is called if the operation fails. |
| 190 * operation fails. | |
| 191 */ | 187 */ |
| 192 void readAsLines(); | 188 void readAsLines(); |
| 193 | 189 |
| 194 /** | 190 /** |
| 195 * Synchronously read the entire file contents as lines of text | 191 * Synchronously read the entire file contents as lines of text |
| 196 * using the given [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By | 192 * using the given [encoding] ('UTF-8', 'ISO-8859-1', 'ASCII'). By |
| 197 * default the encoding is 'UTF-8'. | 193 * default the encoding is 'UTF-8'. |
| 198 */ | 194 */ |
| 199 List<String> readAsLinesSync([String encoding]); | 195 List<String> readAsLinesSync([String encoding]); |
| 200 | 196 |
| 201 /** | 197 /** |
| 202 * Get the name of the file. | 198 * Get the name of the file. |
| 203 */ | 199 */ |
| 204 String get name(); | 200 String get name(); |
| 205 | 201 |
| 206 /** | 202 /** |
| 207 * Sets the handler that gets called when an [exists] operation | 203 * Sets the handler that gets called when an [exists] operation |
| 208 * completes. | 204 * completes. |
| 209 */ | 205 */ |
| 210 void set existsHandler(void handler(bool exists)); | 206 void set onExists(void handler(bool exists)); |
| 211 | 207 |
| 212 /** | 208 /** |
| 213 * Sets the handler that gets called when a [create] operation | 209 * Sets the handler that gets called when a [create] operation |
| 214 * completes. | 210 * completes. |
| 215 */ | 211 */ |
| 216 void set createHandler(void handler()); | 212 void set onCreate(void handler()); |
|
Søren Gjesse
2012/02/29 07:41:24
onCreated?
| |
| 217 | 213 |
| 218 /** | 214 /** |
| 219 * Sets the handler that gets called when a [delete] operation | 215 * Sets the handler that gets called when a [delete] operation |
| 220 * completes. | 216 * completes. |
| 221 */ | 217 */ |
| 222 void set deleteHandler(void handler()); | 218 void set onDelete(void handler()); |
|
Søren Gjesse
2012/02/29 07:41:24
onDeleted?
| |
| 223 | 219 |
| 224 /** | 220 /** |
| 225 * Sets the handler that gets called when a [directory] operation | 221 * Sets the handler that gets called when a [directory] operation |
| 226 * completes. | 222 * completes. |
| 227 */ | 223 */ |
| 228 void set directoryHandler(void handler(Directory directory)); | 224 void set onDirectory(void handler(Directory directory)); |
| 229 | 225 |
| 230 /** | 226 /** |
| 231 * Sets the handler that gets called when an [open] operation | 227 * Sets the handler that gets called when an [open] operation |
| 232 * completes. | 228 * completes. |
| 233 */ | 229 */ |
| 234 void set openHandler(void handler(RandomAccessFile openedFile)); | 230 void set onOpen(void handler(RandomAccessFile openedFile)); |
|
Søren Gjesse
2012/02/29 07:41:24
OnOpened?
| |
| 235 | 231 |
| 236 /** | 232 /** |
| 237 * Set the handler that gets called when a [readAsBytes] operation | 233 * Set the handler that gets called when a [readAsBytes] operation |
| 238 * completes. | 234 * completes. |
| 239 */ | 235 */ |
| 240 void set readAsBytesHandler(void handler(List<int> bytes)); | 236 void set onReadAsBytes(void handler(List<int> bytes)); |
| 241 | 237 |
| 242 /** | 238 /** |
| 243 * Set the handler that gets called when a [readAsText] operation | 239 * Set the handler that gets called when a [readAsText] operation |
| 244 * completes. | 240 * completes. |
| 245 */ | 241 */ |
| 246 void set readAsTextHandler(void handler(String text)); | 242 void set onReadAsText(void handler(String text)); |
| 247 | 243 |
| 248 /** | 244 /** |
| 249 * Set the handler that gets called when a [readAsLines] operation | 245 * Set the handler that gets called when a [readAsLines] operation |
| 250 * completes. | 246 * completes. |
| 251 */ | 247 */ |
| 252 void set readAsLinesHandler(void handler(List<String> lines)); | 248 void set onReadAsLines(void handler(List<String> lines)); |
| 253 | 249 |
| 254 /** | 250 /** |
| 255 * Sets the handler that gets called when a [fullPath] operation | 251 * Sets the handler that gets called when a [fullPath] operation |
| 256 * completes. | 252 * completes. |
| 257 */ | 253 */ |
| 258 void set fullPathHandler(void handler(String path)); | 254 void set onFullPath(void handler(String path)); |
| 259 | 255 |
| 260 /** | 256 /** |
| 261 * Sets the handler that gets called when errors occur during | 257 * Sets the handler that gets called when errors occur during |
| 262 * operations on this file. | 258 * operations on this file. |
| 263 */ | 259 */ |
| 264 void set errorHandler(void handler(String error)); | 260 void set onError(void handler(String error)); |
| 265 } | 261 } |
| 266 | 262 |
| 267 | 263 |
| 268 /** | 264 /** |
| 269 * [RandomAccessFile] provides random access to the data in a | 265 * [RandomAccessFile] provides random access to the data in a |
| 270 * file. [RandomAccessFile] objects are obtained by calling the | 266 * file. [RandomAccessFile] objects are obtained by calling the |
| 271 * [:open:] method on a [File] object. | 267 * [:open:] method on a [File] object. |
| 272 */ | 268 */ |
| 273 interface RandomAccessFile { | 269 interface RandomAccessFile { |
| 274 /** | 270 /** |
| 275 * Close the file. When the file is closed the [closeHandler] is | 271 * Close the file. When the file is closed [onClose] is called. |
| 276 * called. | |
| 277 */ | 272 */ |
| 278 void close(); | 273 void close(); |
| 279 | 274 |
| 280 /** | 275 /** |
| 281 * Synchronously close the file. | 276 * Synchronously close the file. |
| 282 */ | 277 */ |
| 283 void closeSync(); | 278 void closeSync(); |
| 284 | 279 |
| 285 /** | 280 /** |
| 286 * Read a byte from the file. When the byte has been read the | 281 * Read a byte from the file. When the byte has been read the |
| 287 * [readByteHandler] is called with the value. | 282 * [onReadByte] is called with the value. |
| 288 */ | 283 */ |
| 289 void readByte(); | 284 void readByte(); |
| 290 | 285 |
| 291 /** | 286 /** |
| 292 * Synchronously read a single byte from the file. | 287 * Synchronously read a single byte from the file. |
| 293 */ | 288 */ |
| 294 int readByteSync(); | 289 int readByteSync(); |
| 295 | 290 |
| 296 /** | 291 /** |
| 297 * Read a List<int> from the file. When the list has been read the | 292 * Read a List<int> from the file. When the list has been read the |
| 298 * [readListHandler] is called with an integer indicating how much | 293 * [onReadList] is called with an integer indicating how much |
| 299 * was read. | 294 * was read. |
| 300 */ | 295 */ |
| 301 void readList(List<int> buffer, int offset, int bytes); | 296 void readList(List<int> buffer, int offset, int bytes); |
| 302 | 297 |
| 303 /** | 298 /** |
| 304 * Synchronously read a List<int> from the file. Returns the number | 299 * Synchronously read a List<int> from the file. Returns the number |
| 305 * of bytes read. | 300 * of bytes read. |
| 306 */ | 301 */ |
| 307 int readListSync(List<int> buffer, int offset, int bytes); | 302 int readListSync(List<int> buffer, int offset, int bytes); |
| 308 | 303 |
| 309 /** | 304 /** |
| 310 * Write a single byte to the file. If the byte cannot be written | 305 * Write a single byte to the file. If the byte cannot be written |
| 311 * the [errorHandler] is called. When all pending write operations | 306 * [onError] is called. When all pending write operations have |
| 312 * have finished the [noPendingWriteHandler] is called. | 307 * finished [onNoPendingWrite] is called. |
| 313 */ | 308 */ |
| 314 void writeByte(int value); | 309 void writeByte(int value); |
| 315 | 310 |
| 316 /** | 311 /** |
| 317 * Synchronously write a single byte to the file. Returns the | 312 * Synchronously write a single byte to the file. Returns the |
| 318 * number of bytes successfully written. | 313 * number of bytes successfully written. |
| 319 */ | 314 */ |
| 320 int writeByteSync(int value); | 315 int writeByteSync(int value); |
| 321 | 316 |
| 322 /** | 317 /** |
| 323 * Write a List<int> to the file. If the list cannot be written the | 318 * Write a List<int> to the file. If the list cannot be written the |
| 324 * [errorHandler] is called. When all pending write operations have | 319 * [onError] is called. When all pending write operations have |
| 325 * finished the [noPendingWriteHandler] is called. | 320 * finished [onNoPendingWrite] is called. |
| 326 */ | 321 */ |
| 327 void writeList(List<int> buffer, int offset, int bytes); | 322 void writeList(List<int> buffer, int offset, int bytes); |
| 328 | 323 |
| 329 /** | 324 /** |
| 330 * Synchronously write a List<int> to the file. Returns the number | 325 * Synchronously write a List<int> to the file. Returns the number |
| 331 * of bytes successfully written. | 326 * of bytes successfully written. |
| 332 */ | 327 */ |
| 333 int writeListSync(List<int> buffer, int offset, int bytes); | 328 int writeListSync(List<int> buffer, int offset, int bytes); |
| 334 | 329 |
| 335 /** | 330 /** |
| 336 * Write a string to the file. If the string cannot be written the | 331 * Write a string to the file. If the string cannot be written the |
| 337 * [errorHandler] is called. When all pending write operations have | 332 * [onError] is called. When all pending write operations have |
| 338 * finished the [noPendingWriteHandler] is called. | 333 * finished [onNoPendingWrite] is called. |
| 339 */ | 334 */ |
| 340 // TODO(ager): writeString should take an encoding. | 335 // TODO(ager): writeString should take an encoding. |
| 341 void writeString(String string); | 336 void writeString(String string); |
| 342 | 337 |
| 343 /** | 338 /** |
| 344 * Synchronously write a single string to the file. Returns the number | 339 * Synchronously write a single string to the file. Returns the number |
| 345 * of characters successfully written. | 340 * of characters successfully written. |
| 346 */ | 341 */ |
| 347 // TODO(ager): writeStringSync should take an encoding. | 342 // TODO(ager): writeStringSync should take an encoding. |
| 348 int writeStringSync(String string); | 343 int writeStringSync(String string); |
| 349 | 344 |
| 350 /** | 345 /** |
| 351 * Get the current byte position in the file. When the operation | 346 * Get the current byte position in the file. When the operation |
| 352 * completes the [positionHandler] is called with the position. | 347 * completes [onPosition] is called with the position. |
| 353 */ | 348 */ |
| 354 void position(); | 349 void position(); |
| 355 | 350 |
| 356 /** | 351 /** |
| 357 * Synchronously get the current byte position in the file. | 352 * Synchronously get the current byte position in the file. |
| 358 */ | 353 */ |
| 359 int positionSync(); | 354 int positionSync(); |
| 360 | 355 |
| 361 /** | 356 /** |
| 362 * Set the byte position in the file. When the operation completes | 357 * Set the byte position in the file. When the operation completes |
| 363 * the [setPositionHandler] is called. | 358 * [onSetPosition] is called. |
| 364 */ | 359 */ |
| 365 void setPosition(int position); | 360 void setPosition(int position); |
| 366 | 361 |
| 367 /** | 362 /** |
| 368 * Synchronously set the byte position in the file. | 363 * Synchronously set the byte position in the file. |
| 369 */ | 364 */ |
| 370 void setPositionSync(int position); | 365 void setPositionSync(int position); |
| 371 | 366 |
| 372 /** | 367 /** |
| 373 * Truncate (or extend) the file to [length] bytes. When the | 368 * Truncate (or extend) the file to [length] bytes. When the |
| 374 * operation completes successfully the [truncateHandler] is called. | 369 * operation completes successfully [onTruncate] is called. |
| 375 */ | 370 */ |
| 376 void truncate(int length); | 371 void truncate(int length); |
| 377 | 372 |
| 378 /** | 373 /** |
| 379 * Synchronously truncate (or extend) the file to [length] bytes. | 374 * Synchronously truncate (or extend) the file to [length] bytes. |
| 380 */ | 375 */ |
| 381 void truncateSync(int length); | 376 void truncateSync(int length); |
| 382 | 377 |
| 383 /** | 378 /** |
| 384 * Get the length of the file. When the operation completes the | 379 * Get the length of the file. When the operation completes the |
| 385 * [lengthHandler] is called with the length. | 380 * [onLength] is called with the length. |
| 386 */ | 381 */ |
| 387 void length(); | 382 void length(); |
| 388 | 383 |
| 389 /** | 384 /** |
| 390 * Synchronously get the length of the file. | 385 * Synchronously get the length of the file. |
| 391 */ | 386 */ |
| 392 int lengthSync(); | 387 int lengthSync(); |
| 393 | 388 |
| 394 /** | 389 /** |
| 395 * Flush the contents of the file to disk. The [flushHandler] is | 390 * Flush the contents of the file to disk. [onOnFlush] is |
| 396 * called when the flush operation completes. | 391 * called when the flush operation completes. |
| 397 */ | 392 */ |
| 398 void flush(); | 393 void flush(); |
| 399 | 394 |
| 400 /** | 395 /** |
| 401 * Synchronously flush the contents of the file to disk. | 396 * Synchronously flush the contents of the file to disk. |
| 402 */ | 397 */ |
| 403 void flushSync(); | 398 void flushSync(); |
| 404 | 399 |
| 405 /** | 400 /** |
| 406 * Get the name of the file. | 401 * Get the name of the file. |
| 407 */ | 402 */ |
| 408 String get name(); | 403 String get name(); |
| 409 | 404 |
| 410 /** | 405 /** |
| 411 * Sets the handler that gets called when a [close] operation | 406 * Sets the handler that gets called when a [close] operation |
| 412 * completes. | 407 * completes. |
| 413 */ | 408 */ |
| 414 void set closeHandler(void handler()); | 409 void set onClose(void handler()); |
| 415 | 410 |
| 416 /** | 411 /** |
| 417 * Sets the handler that gets called when a [readByte] operation | 412 * Sets the handler that gets called when a [readByte] operation |
| 418 * completes. | 413 * completes. |
| 419 */ | 414 */ |
| 420 void set readByteHandler(void handler(int byte)); | 415 void set onReadByte(void handler(int byte)); |
|
Søren Gjesse
2012/02/29 07:41:24
onByteRead?
| |
| 421 | 416 |
| 422 /** | 417 /** |
| 423 * Sets the handler that gets called when a [readList] operation | 418 * Sets the handler that gets called when a [readList] operation |
| 424 * completes. | 419 * completes. |
| 425 */ | 420 */ |
| 426 void set readListHandler(void handler(int read)); | 421 void set onReadList(void handler(int read)); |
|
Søren Gjesse
2012/02/29 07:41:24
onListRead?
| |
| 427 | 422 |
| 428 /** | 423 /** |
| 429 * Sets the handler that gets called when there are no more write | 424 * Sets the handler that gets called when there are no more write |
| 430 * operations pending for this file. | 425 * operations pending for this file. |
| 431 */ | 426 */ |
| 432 void set noPendingWriteHandler(void handler()); | 427 void set onNoPendingWrite(void handler()); |
|
Søren Gjesse
2012/02/29 07:41:24
onNoPendingWrites (with an s)?
| |
| 433 | 428 |
| 434 /** | 429 /** |
| 435 * Sets the handler that gets called when a [position] operation | 430 * Sets the handler that gets called when a [position] operation |
| 436 * completes. | 431 * completes. |
| 437 */ | 432 */ |
| 438 void set positionHandler(void handler(int position)); | 433 void set onPosition(void handler(int position)); |
| 439 | 434 |
| 440 /** | 435 /** |
| 441 * Sets the handler that gets called when a [setPosition] operation | 436 * Sets the handler that gets called when a [setPosition] operation |
| 442 * completes. | 437 * completes. |
| 443 */ | 438 */ |
| 444 void set setPositionHandler(void handler()); | 439 void set onSetPosition(void handler()); |
|
Søren Gjesse
2012/02/29 07:41:24
OnPositionSet?
| |
| 445 | 440 |
| 446 /** | 441 /** |
| 447 * Sets the handler that gets called when a [truncate] operation | 442 * Sets the handler that gets called when a [truncate] operation |
| 448 * completes. | 443 * completes. |
| 449 */ | 444 */ |
| 450 void set truncateHandler(void handler()); | 445 void set onTruncate(void handler()); |
|
Søren Gjesse
2012/02/29 07:41:24
OnTruncated?
| |
| 451 | 446 |
| 452 /** | 447 /** |
| 453 * Sets the handler that gets called when a [length] operation | 448 * Sets the handler that gets called when a [length] operation |
| 454 * completes. | 449 * completes. |
| 455 */ | 450 */ |
| 456 void set lengthHandler(void handler(int length)); | 451 void set onLength(void handler(int length)); |
| 457 | 452 |
| 458 /** | 453 /** |
| 459 * Sets the handler that gets called when a [flush] operation | 454 * Sets the handler that gets called when a [flush] operation |
| 460 * completes. | 455 * completes. |
| 461 */ | 456 */ |
| 462 void set flushHandler(void handler()); | 457 void set onFlush(void handler()); |
|
Søren Gjesse
2012/02/29 07:41:24
onFlushed?
| |
| 463 | 458 |
| 464 /** | 459 /** |
| 465 * Sets the handler that gets called when errors occur when | 460 * Sets the handler that gets called when errors occur when |
| 466 * operating on this file. | 461 * operating on this file. |
| 467 */ | 462 */ |
| 468 void set errorHandler(void handler(String error)); | 463 void set onError(void handler(String error)); |
| 469 } | 464 } |
| 470 | 465 |
| 471 | 466 |
| 472 class FileIOException implements Exception { | 467 class FileIOException implements Exception { |
| 473 const FileIOException([String this.message = ""]); | 468 const FileIOException([String this.message = ""]); |
| 474 String toString() => "FileIOException: $message"; | 469 String toString() => "FileIOException: $message"; |
| 475 final String message; | 470 final String message; |
| 476 } | 471 } |
| OLD | NEW |