Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: sdk/lib/io/file.dart

Issue 26968003: Remove DirectoryException and LinkException from dart:io and use FileException instaed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge with master. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/directory_impl.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * FileMode describes the modes in which a file can be opened. 8 * FileMode describes the modes in which a file can be opened.
9 */ 9 */
10 class FileMode { 10 class FileMode {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * existing file might fail if there are restrictive permissions on 48 * existing file might fail if there are restrictive permissions on
49 * the file. 49 * the file.
50 */ 50 */
51 Future<File> create(); 51 Future<File> create();
52 52
53 /** 53 /**
54 * Synchronously create the file. Existing files are left untouched 54 * Synchronously create the file. Existing files are left untouched
55 * by [createSync]. Calling [createSync] on an existing file might fail 55 * by [createSync]. Calling [createSync] on an existing file might fail
56 * if there are restrictive permissions on the file. 56 * if there are restrictive permissions on the file.
57 * 57 *
58 * Throws a [FileException] if the operation fails. 58 * Throws a [FileSystemException] if the operation fails.
59 */ 59 */
60 void createSync(); 60 void createSync();
61 61
62 /** 62 /**
63 * Renames this file. Returns a `Future<File>` that completes 63 * Renames this file. Returns a `Future<File>` that completes
64 * with a [File] instance for the renamed file. 64 * with a [File] instance for the renamed file.
65 * 65 *
66 * If [newPath] identifies an existing file, that file is 66 * If [newPath] identifies an existing file, that file is
67 * replaced. If [newPath] identifies an existing directory, the 67 * replaced. If [newPath] identifies an existing directory, the
68 * operation fails and the future completes with an exception. 68 * operation fails and the future completes with an exception.
(...skipping 20 matching lines...) Expand all
89 89
90 /** 90 /**
91 * Get the length of the file. Returns a [:Future<int>:] that 91 * Get the length of the file. Returns a [:Future<int>:] that
92 * completes with the length in bytes. 92 * completes with the length in bytes.
93 */ 93 */
94 Future<int> length(); 94 Future<int> length();
95 95
96 /** 96 /**
97 * Synchronously get the length of the file. 97 * Synchronously get the length of the file.
98 * 98 *
99 * Throws a [FileException] if the operation fails. 99 * Throws a [FileSystemException] if the operation fails.
100 */ 100 */
101 int lengthSync(); 101 int lengthSync();
102 102
103 /** 103 /**
104 * Returns a [File] instance whose path is the absolute path to [this]. 104 * Returns a [File] instance whose path is the absolute path to [this].
105 * 105 *
106 * The absolute path is computed by prefixing 106 * The absolute path is computed by prefixing
107 * a relative path with the current working directory, and returning 107 * a relative path with the current working directory, and returning
108 * an absolute path unchanged. 108 * an absolute path unchanged.
109 */ 109 */
110 File get absolute; 110 File get absolute;
111 111
112 /** 112 /**
113 * Get the last-modified time of the file. Returns a 113 * Get the last-modified time of the file. Returns a
114 * [:Future<DateTime>:] that completes with a [DateTime] object for the 114 * [:Future<DateTime>:] that completes with a [DateTime] object for the
115 * modification date. 115 * modification date.
116 */ 116 */
117 Future<DateTime> lastModified(); 117 Future<DateTime> lastModified();
118 118
119 /** 119 /**
120 * Get the last-modified time of the file. Throws an exception 120 * Get the last-modified time of the file. Throws an exception
121 * if the file does not exist. 121 * if the file does not exist.
122 * 122 *
123 * Throws a [FileException] if the operation fails. 123 * Throws a [FileSystemException] if the operation fails.
124 */ 124 */
125 DateTime lastModifiedSync(); 125 DateTime lastModifiedSync();
126 126
127 /** 127 /**
128 * Open the file for random access operations. Returns a 128 * Open the file for random access operations. Returns a
129 * [:Future<RandomAccessFile>:] that completes with the opened 129 * [:Future<RandomAccessFile>:] that completes with the opened
130 * random access file. [RandomAccessFile]s must be closed using the 130 * random access file. [RandomAccessFile]s must be closed using the
131 * [RandomAccessFile.close] method. 131 * [RandomAccessFile.close] method.
132 * 132 *
133 * Files can be opened in three modes: 133 * Files can be opened in three modes:
(...skipping 10 matching lines...) Expand all
144 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}); 144 Future<RandomAccessFile> open({FileMode mode: FileMode.READ});
145 145
146 /** 146 /**
147 * Synchronously open the file for random access operations. The 147 * Synchronously open the file for random access operations. The
148 * result is a [RandomAccessFile] on which random access operations 148 * result is a [RandomAccessFile] on which random access operations
149 * can be performed. Opened [RandomAccessFile]s must be closed using 149 * can be performed. Opened [RandomAccessFile]s must be closed using
150 * the [RandomAccessFile.close] method. 150 * the [RandomAccessFile.close] method.
151 * 151 *
152 * See [open] for information on the [mode] argument. 152 * See [open] for information on the [mode] argument.
153 * 153 *
154 * Throws a [FileException] if the operation fails. 154 * Throws a [FileSystemException] if the operation fails.
155 */ 155 */
156 RandomAccessFile openSync({FileMode mode: FileMode.READ}); 156 RandomAccessFile openSync({FileMode mode: FileMode.READ});
157 157
158 /** 158 /**
159 * Get the canonical full path corresponding to the file path. 159 * Get the canonical full path corresponding to the file path.
160 * Returns a [:Future<String>:] that completes with the path. 160 * Returns a [:Future<String>:] that completes with the path.
161 * 161 *
162 * *FullPath is deprecated. Use absolutePath or resolveSymbolicLinks 162 * *FullPath is deprecated. Use absolutePath or resolveSymbolicLinks
163 * instead. FullPath will be removed the 23rd of September, 2013.* 163 * instead. FullPath will be removed the 23rd of September, 2013.*
164 */ 164 */
165 @deprecated 165 @deprecated
166 Future<String> fullPath(); 166 Future<String> fullPath();
167 167
168 /** 168 /**
169 * Synchronously get the canonical full path corresponding to the file path. 169 * Synchronously get the canonical full path corresponding to the file path.
170 * 170 *
171 * Throws a [FileException] if the operation fails. 171 * Throws a [FileSystemException] if the operation fails.
172 * 172 *
173 * *FullPathSync is deprecated. Use absolutePathSync or 173 * *FullPathSync is deprecated. Use absolutePathSync or
174 * resolveSymbolicLinksSync instead. FullPathSync will be removed 174 * resolveSymbolicLinksSync instead. FullPathSync will be removed
175 * the 23rd of September, 2013.* 175 * the 23rd of September, 2013.*
176 */ 176 */
177 @deprecated 177 @deprecated
178 String fullPathSync(); 178 String fullPathSync();
179 179
180 /** 180 /**
181 * Create a new independent [Stream] for the contents of this file. 181 * Create a new independent [Stream] for the contents of this file.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 /** 214 /**
215 * Read the entire file contents as a list of bytes. Returns a 215 * Read the entire file contents as a list of bytes. Returns a
216 * [:Future<List<int>>:] that completes with the list of bytes that 216 * [:Future<List<int>>:] that completes with the list of bytes that
217 * is the contents of the file. 217 * is the contents of the file.
218 */ 218 */
219 Future<List<int>> readAsBytes(); 219 Future<List<int>> readAsBytes();
220 220
221 /** 221 /**
222 * Synchronously read the entire file contents as a list of bytes. 222 * Synchronously read the entire file contents as a list of bytes.
223 * 223 *
224 * Throws a [FileException] if the operation fails. 224 * Throws a [FileSystemException] if the operation fails.
225 */ 225 */
226 List<int> readAsBytesSync(); 226 List<int> readAsBytesSync();
227 227
228 /** 228 /**
229 * Read the entire file contents as a string using the given 229 * Read the entire file contents as a string using the given
230 * [Encoding]. 230 * [Encoding].
231 * 231 *
232 * Returns a [:Future<String>:] that completes with the string once 232 * Returns a [:Future<String>:] that completes with the string once
233 * the file contents has been read. 233 * the file contents has been read.
234 */ 234 */
235 Future<String> readAsString({Encoding encoding: UTF8}); 235 Future<String> readAsString({Encoding encoding: UTF8});
236 236
237 /** 237 /**
238 * Synchronously read the entire file contents as a string using the 238 * Synchronously read the entire file contents as a string using the
239 * given [Encoding]. 239 * given [Encoding].
240 * 240 *
241 * Throws a [FileException] if the operation fails. 241 * Throws a [FileSystemException] if the operation fails.
242 */ 242 */
243 String readAsStringSync({Encoding encoding: UTF8}); 243 String readAsStringSync({Encoding encoding: UTF8});
244 244
245 /** 245 /**
246 * Read the entire file contents as lines of text using the given 246 * Read the entire file contents as lines of text using the given
247 * [Encoding]. 247 * [Encoding].
248 * 248 *
249 * Returns a [:Future<List<String>>:] that completes with the lines 249 * Returns a [:Future<List<String>>:] that completes with the lines
250 * once the file contents has been read. 250 * once the file contents has been read.
251 */ 251 */
252 Future<List<String>> readAsLines({Encoding encoding: UTF8}); 252 Future<List<String>> readAsLines({Encoding encoding: UTF8});
253 253
254 /** 254 /**
255 * Synchronously read the entire file contents as lines of text 255 * Synchronously read the entire file contents as lines of text
256 * using the given [Encoding]. 256 * using the given [Encoding].
257 * 257 *
258 * Throws a [FileException] if the operation fails. 258 * Throws a [FileSystemException] if the operation fails.
259 */ 259 */
260 List<String> readAsLinesSync({Encoding encoding: UTF8}); 260 List<String> readAsLinesSync({Encoding encoding: UTF8});
261 261
262 /** 262 /**
263 * Write a list of bytes to a file. 263 * Write a list of bytes to a file.
264 * 264 *
265 * Opens the file, writes the list of bytes to it, and closes the file. 265 * Opens the file, writes the list of bytes to it, and closes the file.
266 * Returns a [:Future<File>:] that completes with this [File] object once 266 * Returns a [:Future<File>:] that completes with this [File] object once
267 * the entire operation has completed. 267 * the entire operation has completed.
268 * 268 *
269 * By default [writeAsBytes] creates the file for writing and truncates the 269 * By default [writeAsBytes] creates the file for writing and truncates the
270 * file if it already exists. In order to append the bytes to an existing 270 * file if it already exists. In order to append the bytes to an existing
271 * file, pass [FileMode.APPEND] as the optional mode parameter. 271 * file, pass [FileMode.APPEND] as the optional mode parameter.
272 */ 272 */
273 Future<File> writeAsBytes(List<int> bytes, {FileMode mode: FileMode.WRITE}); 273 Future<File> writeAsBytes(List<int> bytes, {FileMode mode: FileMode.WRITE});
274 274
275 /** 275 /**
276 * Synchronously write a list of bytes to a file. 276 * Synchronously write a list of bytes to a file.
277 * 277 *
278 * Opens the file, writes the list of bytes to it and closes the file. 278 * Opens the file, writes the list of bytes to it and closes the file.
279 * 279 *
280 * By default [writeAsBytesSync] creates the file for writing and truncates 280 * By default [writeAsBytesSync] creates the file for writing and truncates
281 * the file if it already exists. In order to append the bytes to an existing 281 * the file if it already exists. In order to append the bytes to an existing
282 * file, pass [FileMode.APPEND] as the optional mode parameter. 282 * file, pass [FileMode.APPEND] as the optional mode parameter.
283 * 283 *
284 * Throws a [FileException] if the operation fails. 284 * Throws a [FileSystemException] if the operation fails.
285 */ 285 */
286 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE}); 286 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE});
287 287
288 /** 288 /**
289 * Write a string to a file. 289 * Write a string to a file.
290 * 290 *
291 * Opens the file, writes the string in the given encoding, and closes the 291 * Opens the file, writes the string in the given encoding, and closes the
292 * file. Returns a [:Future<File>:] that completes with this [File] object 292 * file. Returns a [:Future<File>:] that completes with this [File] object
293 * once the entire operation has completed. 293 * once the entire operation has completed.
294 * 294 *
295 * By default [writeAsString] creates the file for writing and truncates the 295 * By default [writeAsString] creates the file for writing and truncates the
296 * file if it already exists. In order to append the bytes to an existing 296 * file if it already exists. In order to append the bytes to an existing
297 * file, pass [FileMode.APPEND] as the optional mode parameter. 297 * file, pass [FileMode.APPEND] as the optional mode parameter.
298 */ 298 */
299 Future<File> writeAsString(String contents, 299 Future<File> writeAsString(String contents,
300 {FileMode mode: FileMode.WRITE, 300 {FileMode mode: FileMode.WRITE,
301 Encoding encoding: UTF8}); 301 Encoding encoding: UTF8});
302 302
303 /** 303 /**
304 * Synchronously write a string to a file. 304 * Synchronously write a string to a file.
305 * 305 *
306 * Opens the file, writes the string in the given encoding, and closes the 306 * Opens the file, writes the string in the given encoding, and closes the
307 * file. 307 * file.
308 * 308 *
309 * By default [writeAsStringSync] creates the file for writing and 309 * By default [writeAsStringSync] creates the file for writing and
310 * truncates the file if it already exists. In order to append the bytes 310 * truncates the file if it already exists. In order to append the bytes
311 * to an existing file, pass [FileMode.APPEND] as the optional mode 311 * to an existing file, pass [FileMode.APPEND] as the optional mode
312 * parameter. 312 * parameter.
313 * 313 *
314 * Throws a [FileException] if the operation fails. 314 * Throws a [FileSystemException] if the operation fails.
315 */ 315 */
316 void writeAsStringSync(String contents, 316 void writeAsStringSync(String contents,
317 {FileMode mode: FileMode.WRITE, 317 {FileMode mode: FileMode.WRITE,
318 Encoding encoding: UTF8}); 318 Encoding encoding: UTF8});
319 319
320 /** 320 /**
321 * Get the path of the file. 321 * Get the path of the file.
322 */ 322 */
323 String get path; 323 String get path;
324 } 324 }
325 325
326 326
327 /** 327 /**
328 * [RandomAccessFile] provides random access to the data in a 328 * [RandomAccessFile] provides random access to the data in a
329 * file. [RandomAccessFile] objects are obtained by calling the 329 * file. [RandomAccessFile] objects are obtained by calling the
330 * [:open:] method on a [File] object. 330 * [:open:] method on a [File] object.
331 */ 331 */
332 abstract class RandomAccessFile { 332 abstract class RandomAccessFile {
333 /** 333 /**
334 * Closes the file. Returns a [:Future<RandomAccessFile>:] that 334 * Closes the file. Returns a [:Future<RandomAccessFile>:] that
335 * completes with this RandomAccessFile when it has been closed. 335 * completes with this RandomAccessFile when it has been closed.
336 */ 336 */
337 Future<RandomAccessFile> close(); 337 Future<RandomAccessFile> close();
338 338
339 /** 339 /**
340 * Synchronously closes the file. 340 * Synchronously closes the file.
341 * 341 *
342 * Throws a [FileException] if the operation fails. 342 * Throws a [FileSystemException] if the operation fails.
343 */ 343 */
344 void closeSync(); 344 void closeSync();
345 345
346 /** 346 /**
347 * Reads a byte from the file. Returns a [:Future<int>:] that 347 * Reads a byte from the file. Returns a [:Future<int>:] that
348 * completes with the byte, or with -1 if end-of-file has been reached. 348 * completes with the byte, or with -1 if end-of-file has been reached.
349 */ 349 */
350 Future<int> readByte(); 350 Future<int> readByte();
351 351
352 /** 352 /**
353 * Synchronously reads a single byte from the file. If end-of-file 353 * Synchronously reads a single byte from the file. If end-of-file
354 * has been reached -1 is returned. 354 * has been reached -1 is returned.
355 * 355 *
356 * Throws a [FileException] if the operation fails. 356 * Throws a [FileSystemException] if the operation fails.
357 */ 357 */
358 int readByteSync(); 358 int readByteSync();
359 359
360 /** 360 /**
361 * Reads [bytes] bytes from a file and returns the result as a list of bytes. 361 * Reads [bytes] bytes from a file and returns the result as a list of bytes.
362 */ 362 */
363 Future<List<int>> read(int bytes); 363 Future<List<int>> read(int bytes);
364 364
365 /** 365 /**
366 * Synchronously reads a maximum of [bytes] bytes from a file and 366 * Synchronously reads a maximum of [bytes] bytes from a file and
367 * returns the result in a list of bytes. 367 * returns the result in a list of bytes.
368 * 368 *
369 * Throws a [FileException] if the operation fails. 369 * Throws a [FileSystemException] if the operation fails.
370 */ 370 */
371 List<int> readSync(int bytes); 371 List<int> readSync(int bytes);
372 372
373 /** 373 /**
374 * Reads into an existing List<int> from the file. If [start] is present, the 374 * Reads into an existing List<int> from the file. If [start] is present, the
375 * bytes will be filled into [buffer] from at index [start], otherwise index 375 * bytes will be filled into [buffer] from at index [start], otherwise index
376 * 0. If [end] is present, the [end] - [start] bytes will be read into 376 * 0. If [end] is present, the [end] - [start] bytes will be read into
377 * [buffer], otherwise up to [buffer.length]. If [end] == [start] nothing 377 * [buffer], otherwise up to [buffer.length]. If [end] == [start] nothing
378 * happends. 378 * happends.
379 * 379 *
380 * Returns a [:Future<int>:] that completes with the number of bytes read. 380 * Returns a [:Future<int>:] that completes with the number of bytes read.
381 */ 381 */
382 Future<int> readInto(List<int> buffer, [int start, int end]); 382 Future<int> readInto(List<int> buffer, [int start, int end]);
383 383
384 /** 384 /**
385 * Synchronously reads into an existing List<int> from the file. If [start] is 385 * Synchronously reads into an existing List<int> from the file. If [start] is
386 * present, the bytes will be filled into [buffer] from at index [start], 386 * present, the bytes will be filled into [buffer] from at index [start],
387 * otherwise index 0. If [end] is present, the [end] - [start] bytes will be 387 * otherwise index 0. If [end] is present, the [end] - [start] bytes will be
388 * read into [buffer], otherwise up to [buffer.length]. If [end] == [start] 388 * read into [buffer], otherwise up to [buffer.length]. If [end] == [start]
389 * nothing happends. 389 * nothing happends.
390 * 390 *
391 * Throws a [FileException] if the operation fails. 391 * Throws a [FileSystemException] if the operation fails.
392 */ 392 */
393 int readIntoSync(List<int> buffer, [int start, int end]); 393 int readIntoSync(List<int> buffer, [int start, int end]);
394 394
395 /** 395 /**
396 * Writes a single byte to the file. Returns a 396 * Writes a single byte to the file. Returns a
397 * [:Future<RandomAccessFile>:] that completes with this 397 * [:Future<RandomAccessFile>:] that completes with this
398 * RandomAccessFile when the write completes. 398 * RandomAccessFile when the write completes.
399 */ 399 */
400 Future<RandomAccessFile> writeByte(int value); 400 Future<RandomAccessFile> writeByte(int value);
401 401
402 /** 402 /**
403 * Synchronously writes a single byte to the file. Returns the 403 * Synchronously writes a single byte to the file. Returns the
404 * number of bytes successfully written. 404 * number of bytes successfully written.
405 * 405 *
406 * Throws a [FileException] if the operation fails. 406 * Throws a [FileSystemException] if the operation fails.
407 */ 407 */
408 int writeByteSync(int value); 408 int writeByteSync(int value);
409 409
410 /** 410 /**
411 * Writes from a [List<int>] to the file. It will read the buffer from index 411 * Writes from a [List<int>] to the file. It will read the buffer from index
412 * [start] to index [end]. If [start] is omitted, it'll start from index 0. 412 * [start] to index [end]. If [start] is omitted, it'll start from index 0.
413 * If [end] is omitted, it will write to end of [buffer]. 413 * If [end] is omitted, it will write to end of [buffer].
414 * 414 *
415 * Returns a [:Future<RandomAccessFile>:] that completes with this 415 * Returns a [:Future<RandomAccessFile>:] that completes with this
416 * [RandomAccessFile] when the write completes. 416 * [RandomAccessFile] when the write completes.
417 */ 417 */
418 Future<RandomAccessFile> writeFrom(List<int> buffer, [int start, int end]); 418 Future<RandomAccessFile> writeFrom(List<int> buffer, [int start, int end]);
419 419
420 /** 420 /**
421 * Synchronously writes from a [List<int>] to the file. It will read the 421 * Synchronously writes from a [List<int>] to the file. It will read the
422 * buffer from index [start] to index [end]. If [start] is omitted, it'll 422 * buffer from index [start] to index [end]. If [start] is omitted, it'll
423 * start from index 0. If [end] is omitted, it will write to the end of 423 * start from index 0. If [end] is omitted, it will write to the end of
424 * [buffer]. 424 * [buffer].
425 * 425 *
426 * Throws a [FileException] if the operation fails. 426 * Throws a [FileSystemException] if the operation fails.
427 */ 427 */
428 void writeFromSync(List<int> buffer, [int start, int end]); 428 void writeFromSync(List<int> buffer, [int start, int end]);
429 429
430 /** 430 /**
431 * Writes a string to the file using the given [Encoding]. Returns a 431 * Writes a string to the file using the given [Encoding]. Returns a
432 * [:Future<RandomAccessFile>:] that completes with this 432 * [:Future<RandomAccessFile>:] that completes with this
433 * RandomAccessFile when the write completes. 433 * RandomAccessFile when the write completes.
434 */ 434 */
435 Future<RandomAccessFile> writeString(String string, 435 Future<RandomAccessFile> writeString(String string,
436 {Encoding encoding: UTF8}); 436 {Encoding encoding: UTF8});
437 437
438 /** 438 /**
439 * Synchronously writes a single string to the file using the given 439 * Synchronously writes a single string to the file using the given
440 * [Encoding]. 440 * [Encoding].
441 * 441 *
442 * Throws a [FileException] if the operation fails. 442 * Throws a [FileSystemException] if the operation fails.
443 */ 443 */
444 void writeStringSync(String string, 444 void writeStringSync(String string,
445 {Encoding encoding: UTF8}); 445 {Encoding encoding: UTF8});
446 446
447 /** 447 /**
448 * Gets the current byte position in the file. Returns a 448 * Gets the current byte position in the file. Returns a
449 * [:Future<int>:] that completes with the position. 449 * [:Future<int>:] that completes with the position.
450 */ 450 */
451 Future<int> position(); 451 Future<int> position();
452 452
453 /** 453 /**
454 * Synchronously gets the current byte position in the file. 454 * Synchronously gets the current byte position in the file.
455 * 455 *
456 * Throws a [FileException] if the operation fails. 456 * Throws a [FileSystemException] if the operation fails.
457 */ 457 */
458 int positionSync(); 458 int positionSync();
459 459
460 /** 460 /**
461 * Sets the byte position in the file. Returns a 461 * Sets the byte position in the file. Returns a
462 * [:Future<RandomAccessFile>:] that completes with this 462 * [:Future<RandomAccessFile>:] that completes with this
463 * RandomAccessFile when the position has been set. 463 * RandomAccessFile when the position has been set.
464 */ 464 */
465 Future<RandomAccessFile> setPosition(int position); 465 Future<RandomAccessFile> setPosition(int position);
466 466
467 /** 467 /**
468 * Synchronously sets the byte position in the file. 468 * Synchronously sets the byte position in the file.
469 * 469 *
470 * Throws a [FileException] if the operation fails. 470 * Throws a [FileSystemException] if the operation fails.
471 */ 471 */
472 void setPositionSync(int position); 472 void setPositionSync(int position);
473 473
474 /** 474 /**
475 * Truncates (or extends) the file to [length] bytes. Returns a 475 * Truncates (or extends) the file to [length] bytes. Returns a
476 * [:Future<RandomAccessFile>:] that completes with this 476 * [:Future<RandomAccessFile>:] that completes with this
477 * RandomAccessFile when the truncation has been performed. 477 * RandomAccessFile when the truncation has been performed.
478 */ 478 */
479 Future<RandomAccessFile> truncate(int length); 479 Future<RandomAccessFile> truncate(int length);
480 480
481 /** 481 /**
482 * Synchronously truncates (or extends) the file to [length] bytes. 482 * Synchronously truncates (or extends) the file to [length] bytes.
483 * 483 *
484 * Throws a [FileException] if the operation fails. 484 * Throws a [FileSystemException] if the operation fails.
485 */ 485 */
486 void truncateSync(int length); 486 void truncateSync(int length);
487 487
488 /** 488 /**
489 * Gets the length of the file. Returns a [:Future<int>:] that 489 * Gets the length of the file. Returns a [:Future<int>:] that
490 * completes with the length in bytes. 490 * completes with the length in bytes.
491 */ 491 */
492 Future<int> length(); 492 Future<int> length();
493 493
494 /** 494 /**
495 * Synchronously gets the length of the file. 495 * Synchronously gets the length of the file.
496 * 496 *
497 * Throws a [FileException] if the operation fails. 497 * Throws a [FileSystemException] if the operation fails.
498 */ 498 */
499 int lengthSync(); 499 int lengthSync();
500 500
501 /** 501 /**
502 * Flushes the contents of the file to disk. Returns a 502 * Flushes the contents of the file to disk. Returns a
503 * [:Future<RandomAccessFile>:] that completes with this 503 * [:Future<RandomAccessFile>:] that completes with this
504 * RandomAccessFile when the flush operation completes. 504 * RandomAccessFile when the flush operation completes.
505 */ 505 */
506 Future<RandomAccessFile> flush(); 506 Future<RandomAccessFile> flush();
507 507
508 /** 508 /**
509 * Synchronously flushes the contents of the file to disk. 509 * Synchronously flushes the contents of the file to disk.
510 * 510 *
511 * Throws a [FileException] if the operation fails. 511 * Throws a [FileSystemException] if the operation fails.
512 */ 512 */
513 void flushSync(); 513 void flushSync();
514 514
515 /** 515 /**
516 * Returns a human-readable string for this RandomAccessFile instance. 516 * Returns a human-readable string for this RandomAccessFile instance.
517 */ 517 */
518 String toString(); 518 String toString();
519 519
520 /** 520 /**
521 * Gets the path of the file underlying this RandomAccessFile. 521 * Gets the path of the file underlying this RandomAccessFile.
522 */ 522 */
523 String get path; 523 String get path;
524 } 524 }
525 525
526 526
527 class FileException implements IOException { 527 class FileSystemException implements IOException {
528 final String message; 528 final String message;
529 final String path; 529 final String path;
530 final OSError osError; 530 final OSError osError;
531 const FileException([String this.message = "", 531 const FileSystemException([String this.message = "",
532 String this.path = "", 532 String this.path = "",
533 OSError this.osError]); 533 OSError this.osError]);
534 534
535 String toString() { 535 String toString() {
536 StringBuffer sb = new StringBuffer(); 536 StringBuffer sb = new StringBuffer();
537 sb.write("FileException"); 537 sb.write("FileSystemException");
538 if (!message.isEmpty) { 538 if (!message.isEmpty) {
539 sb.write(": $message"); 539 sb.write(": $message");
540 if (path != null) { 540 if (path != null) {
541 sb.write(", path = $path"); 541 sb.write(", path = $path");
542 } 542 }
543 if (osError != null) { 543 if (osError != null) {
544 sb.write(" ($osError)"); 544 sb.write(" ($osError)");
545 } 545 }
546 } else if (osError != null) { 546 } else if (osError != null) {
547 sb.write(": osError"); 547 sb.write(": osError");
548 if (path != null) { 548 if (path != null) {
549 sb.write(", path = $path"); 549 sb.write(", path = $path");
550 } 550 }
551 } 551 }
552 return sb.toString(); 552 return sb.toString();
553 } 553 }
554 } 554 }
OLDNEW
« no previous file with comments | « sdk/lib/io/directory_impl.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698