| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 interface File factory _File { | 5 interface File factory _File { |
| 6 /** | 6 /** |
| 7 * Create a File object. | 7 * Create a File object. |
| 8 */ | 8 */ |
| 9 File(String name); | 9 File(String name); |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 */ | 42 */ |
| 43 void delete(); | 43 void delete(); |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Synchronously delete the file. | 46 * Synchronously delete the file. |
| 47 */ | 47 */ |
| 48 void deleteSync(); | 48 void deleteSync(); |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Open the file for random access operations. When the file is | 51 * Open the file for random access operations. When the file is |
| 52 * opened the openHandler is called. Opened files must be closed | 52 * opened the openHandler is called with the resulting |
| 53 * using the [close] method. By default writable is false. | 53 * RandomAccessFile. RandomAccessFiles must be closed using the |
| 54 * close method. By default writable is false. |
| 54 */ | 55 */ |
| 55 void open([bool writable]); | 56 void open([bool writable]); |
| 56 | 57 |
| 57 /** | 58 /** |
| 58 * Synchronously open the file for random access operations. Opened | 59 * Synchronously open the file for random access operations. The |
| 59 * files must be closed using the [close] method. By default | 60 * result is a RandomAccessFile on which random access operations |
| 60 * writable is false. | 61 * can be performed. Opened RandomAccessFiles must be closed using |
| 62 * the close method. By default writable is false. |
| 61 */ | 63 */ |
| 62 void openSync([bool writable]); | 64 RandomAccessFile openSync([bool writable]); |
| 63 | 65 |
| 64 /** | 66 /** |
| 67 * Get the canonical full path corresponding to the file name. The |
| 68 * [fullPathHandler] is called when the fullPath operation |
| 69 * completes. |
| 70 */ |
| 71 String fullPath(); |
| 72 |
| 73 /** |
| 74 * Synchronously get the canonical full path corresponding to the file name. |
| 75 */ |
| 76 String fullPathSync(); |
| 77 |
| 78 /** |
| 79 * Create a new independent input stream for the file. The file |
| 80 * input stream must be closed when no longer used to free up |
| 81 * system resources. |
| 82 */ |
| 83 FileInputStream openInputStream(); |
| 84 |
| 85 /** |
| 86 * Creates a new independent output stream for the file. The file |
| 87 * output stream must be closed when no longer used to free up |
| 88 * system resources. |
| 89 */ |
| 90 FileOutputStream openOutputStream(); |
| 91 |
| 92 /** |
| 93 * Get the name of the file. |
| 94 */ |
| 95 String get name(); |
| 96 |
| 97 // Event handlers. |
| 98 void set existsHandler(void handler(bool exists)); |
| 99 void set createHandler(void handler()); |
| 100 void set deleteHandler(void handler()); |
| 101 void set openHandler(void handler(RandomAccessFile openedFile)); |
| 102 void set fullPathHandler(void handler(String path)); |
| 103 void set errorHandler(void handler(String error)); |
| 104 } |
| 105 |
| 106 |
| 107 interface RandomAccessFile { |
| 108 /** |
| 65 * Close the file. When the file is closed the closeHandler is | 109 * Close the file. When the file is closed the closeHandler is |
| 66 * called. | 110 * called. |
| 67 */ | 111 */ |
| 68 void close(); | 112 void close(); |
| 69 | 113 |
| 70 /** | 114 /** |
| 71 * Synchronously close the file. | 115 * Synchronously close the file. |
| 72 */ | 116 */ |
| 73 void closeSync(); | 117 void closeSync(); |
| 74 | 118 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 * called when the flush operation completes. | 231 * called when the flush operation completes. |
| 188 */ | 232 */ |
| 189 void flush(); | 233 void flush(); |
| 190 | 234 |
| 191 /** | 235 /** |
| 192 * Synchronously flush the contents of the file to disk. | 236 * Synchronously flush the contents of the file to disk. |
| 193 */ | 237 */ |
| 194 void flushSync(); | 238 void flushSync(); |
| 195 | 239 |
| 196 /** | 240 /** |
| 197 * Get the canonical full path corresponding to the file name. The | |
| 198 * [fullPathHandler] is called when the fullPath operation | |
| 199 * completes. | |
| 200 */ | |
| 201 String fullPath(); | |
| 202 | |
| 203 /** | |
| 204 * Synchronously get the canonical full path corresponding to the file name. | |
| 205 */ | |
| 206 String fullPathSync(); | |
| 207 | |
| 208 /** | |
| 209 * Create a new independent input stream for the file. The file | |
| 210 * input stream must be closed when no longer used. | |
| 211 */ | |
| 212 FileInputStream openInputStream(); | |
| 213 | |
| 214 /** | |
| 215 * Creates a new independent output stream for the file. The file | |
| 216 * output stream must be closed when no longer used. | |
| 217 */ | |
| 218 FileOutputStream openOutputStream(); | |
| 219 | |
| 220 /** | |
| 221 * Get the name of the file. | 241 * Get the name of the file. |
| 222 */ | 242 */ |
| 223 String get name(); | 243 String get name(); |
| 224 | 244 |
| 225 // Event handlers. | |
| 226 void set existsHandler(void handler(bool exists)); | |
| 227 void set createHandler(void handler()); | |
| 228 void set deleteHandler(void handler()); | |
| 229 void set openHandler(void handler()); | |
| 230 void set closeHandler(void handler()); | 245 void set closeHandler(void handler()); |
| 231 void set readByteHandler(void handler(int byte)); | 246 void set readByteHandler(void handler(int byte)); |
| 232 void set readListHandler(void handler(int read)); | 247 void set readListHandler(void handler(int read)); |
| 233 void set noPendingWriteHandler(void handler()); | 248 void set noPendingWriteHandler(void handler()); |
| 234 void set positionHandler(void handler(int position)); | 249 void set positionHandler(void handler(int position)); |
| 235 void set setPositionHandler(void handler()); | 250 void set setPositionHandler(void handler()); |
| 236 void set truncateHandler(void handler()); | 251 void set truncateHandler(void handler()); |
| 237 void set lengthHandler(void handler(int length)); | 252 void set lengthHandler(void handler(int length)); |
| 238 void set flushHandler(void handler()); | 253 void set flushHandler(void handler()); |
| 239 void set fullPathHandler(void handler(String path)); | |
| 240 void set errorHandler(void handler(String error)); | 254 void set errorHandler(void handler(String error)); |
| 241 } | 255 } |
| 242 | 256 |
| 243 | 257 |
| 244 interface FileInputStream extends InputStream { | 258 interface FileInputStream extends InputStream { |
| 245 void close(); | 259 void close(); |
| 246 } | 260 } |
| 247 | 261 |
| 248 | 262 |
| 249 interface FileOutputStream extends OutputStream { | 263 interface FileOutputStream extends OutputStream { |
| 250 } | 264 } |
| 251 | 265 |
| 252 | 266 |
| 253 class FileIOException implements Exception { | 267 class FileIOException implements Exception { |
| 254 const FileIOException([String this.message = ""]); | 268 const FileIOException([String this.message = ""]); |
| 255 String toString() => "FileIOException: $message"; | 269 String toString() => "FileIOException: $message"; |
| 256 final String message; | 270 final String message; |
| 257 } | 271 } |
| OLD | NEW |