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. | |
Søren Gjesse
2011/12/08 17:25:58
Maybe add "to free up system resources".
Mads Ager (google)
2011/12/08 19:37:01
Done.
| |
81 */ | |
82 FileInputStream openInputStream(); | |
83 | |
84 /** | |
85 * Creates a new independent output stream for the file. The file | |
86 * output stream must be closed when no longer used. | |
Søren Gjesse
2011/12/08 17:25:58
Ditto.
Mads Ager (google)
2011/12/08 19:37:01
Done.
| |
87 */ | |
88 FileOutputStream openOutputStream(); | |
89 | |
90 /** | |
91 * Get the name of the file. | |
92 */ | |
93 String get name(); | |
94 | |
95 // Event handlers. | |
96 void set existsHandler(void handler(bool exists)); | |
97 void set createHandler(void handler()); | |
98 void set deleteHandler(void handler()); | |
99 void set openHandler(void handler(RandomAccessFile openedFile)); | |
100 void set fullPathHandler(void handler(String path)); | |
101 void set errorHandler(void handler(String error)); | |
102 } | |
103 | |
104 | |
105 interface RandomAccessFile { | |
106 /** | |
65 * Close the file. When the file is closed the closeHandler is | 107 * Close the file. When the file is closed the closeHandler is |
66 * called. | 108 * called. |
67 */ | 109 */ |
68 void close(); | 110 void close(); |
69 | 111 |
70 /** | 112 /** |
71 * Synchronously close the file. | 113 * Synchronously close the file. |
72 */ | 114 */ |
73 void closeSync(); | 115 void closeSync(); |
74 | 116 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 * called when the flush operation completes. | 229 * called when the flush operation completes. |
188 */ | 230 */ |
189 void flush(); | 231 void flush(); |
190 | 232 |
191 /** | 233 /** |
192 * Synchronously flush the contents of the file to disk. | 234 * Synchronously flush the contents of the file to disk. |
193 */ | 235 */ |
194 void flushSync(); | 236 void flushSync(); |
195 | 237 |
196 /** | 238 /** |
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. | 239 * Get the name of the file. |
222 */ | 240 */ |
223 String get name(); | 241 String get name(); |
224 | 242 |
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()); | 243 void set closeHandler(void handler()); |
231 void set readByteHandler(void handler(int byte)); | 244 void set readByteHandler(void handler(int byte)); |
232 void set readListHandler(void handler(int read)); | 245 void set readListHandler(void handler(int read)); |
233 void set noPendingWriteHandler(void handler()); | 246 void set noPendingWriteHandler(void handler()); |
234 void set positionHandler(void handler(int position)); | 247 void set positionHandler(void handler(int position)); |
235 void set setPositionHandler(void handler()); | 248 void set setPositionHandler(void handler()); |
236 void set truncateHandler(void handler()); | 249 void set truncateHandler(void handler()); |
237 void set lengthHandler(void handler(int length)); | 250 void set lengthHandler(void handler(int length)); |
238 void set flushHandler(void handler()); | 251 void set flushHandler(void handler()); |
239 void set fullPathHandler(void handler(String path)); | |
240 void set errorHandler(void handler(String error)); | 252 void set errorHandler(void handler(String error)); |
241 } | 253 } |
242 | 254 |
243 | 255 |
244 interface FileInputStream extends InputStream { | 256 interface FileInputStream extends InputStream { |
245 void close(); | 257 void close(); |
246 } | 258 } |
247 | 259 |
248 | 260 |
249 interface FileOutputStream extends OutputStream { | 261 interface FileOutputStream extends OutputStream { |
250 } | 262 } |
251 | 263 |
252 | 264 |
253 class FileIOException implements Exception { | 265 class FileIOException implements Exception { |
254 const FileIOException([String this.message = ""]); | 266 const FileIOException([String this.message = ""]); |
255 String toString() => "FileIOException: $message"; | 267 String toString() => "FileIOException: $message"; |
256 final String message; | 268 final String message; |
257 } | 269 } |
OLD | NEW |