OLD | NEW |
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 { |
11 /// The [FileMode] for opening a file only for reading. | 11 /// The [FileMode] for opening a file only for reading. |
12 static const READ = const FileMode._internal(0); | 12 static const READ = const FileMode._internal(0); |
13 /// The [FileMode] for opening a file for reading and writing. The file will | 13 /// The [FileMode] for opening a file for reading and writing. The file will |
14 /// be overwritten. If the file does not exist, it will be created. | 14 /// be overwritten. If the file does not exist, it will be created. |
15 static const WRITE = const FileMode._internal(1); | 15 static const WRITE = const FileMode._internal(1); |
16 /// The [FileMode] for opening a file for reading a file and writing to the | 16 /// The [FileMode] for opening a file for reading a file and writing to the |
17 /// end of it. If the file does not exist, it will be created. | 17 /// end of it. If the file does not exist, it will be created. |
18 static const APPEND = const FileMode._internal(2); | 18 static const APPEND = const FileMode._internal(2); |
19 const FileMode._internal(int this._mode); | |
20 final int _mode; | 19 final int _mode; |
| 20 |
| 21 const FileMode._internal(this._mode); |
21 } | 22 } |
22 | 23 |
23 /// The [FileMode] for opening a file only for reading. | 24 /// The [FileMode] for opening a file only for reading. |
24 const READ = FileMode.READ; | 25 const READ = FileMode.READ; |
25 /// The [FileMode] for opening a file for reading and writing. The file will be | 26 /// The [FileMode] for opening a file for reading and writing. The file will be |
26 /// overwritten. If the file does not exist, it will be created. | 27 /// overwritten. If the file does not exist, it will be created. |
27 const WRITE = FileMode.WRITE; | 28 const WRITE = FileMode.WRITE; |
28 /// The [FileMode] for opening a file for reading a file and writing to the end | 29 /// The [FileMode] for opening a file for reading a file and writing to the end |
29 /// of it. If the file does not exist, it will be created. | 30 /// of it. If the file does not exist, it will be created. |
30 const APPEND = FileMode.APPEND; | 31 const APPEND = FileMode.APPEND; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 * Gets the path of the file underlying this RandomAccessFile. | 558 * Gets the path of the file underlying this RandomAccessFile. |
558 */ | 559 */ |
559 String get path; | 560 String get path; |
560 } | 561 } |
561 | 562 |
562 | 563 |
563 class FileSystemException implements IOException { | 564 class FileSystemException implements IOException { |
564 final String message; | 565 final String message; |
565 final String path; | 566 final String path; |
566 final OSError osError; | 567 final OSError osError; |
567 const FileSystemException([String this.message = "", | 568 const FileSystemException([this.message = "", this.path = "", this.osError]); |
568 String this.path = "", | |
569 OSError this.osError]); | |
570 | 569 |
571 String toString() { | 570 String toString() { |
572 StringBuffer sb = new StringBuffer(); | 571 StringBuffer sb = new StringBuffer(); |
573 sb.write("FileSystemException"); | 572 sb.write("FileSystemException"); |
574 if (!message.isEmpty) { | 573 if (!message.isEmpty) { |
575 sb.write(": $message"); | 574 sb.write(": $message"); |
576 if (path != null) { | 575 if (path != null) { |
577 sb.write(", path = $path"); | 576 sb.write(", path = $path"); |
578 } | 577 } |
579 if (osError != null) { | 578 if (osError != null) { |
580 sb.write(" ($osError)"); | 579 sb.write(" ($osError)"); |
581 } | 580 } |
582 } else if (osError != null) { | 581 } else if (osError != null) { |
583 sb.write(": osError"); | 582 sb.write(": osError"); |
584 if (path != null) { | 583 if (path != null) { |
585 sb.write(", path = $path"); | 584 sb.write(", path = $path"); |
586 } | 585 } |
587 } | 586 } |
588 return sb.toString(); | 587 return sb.toString(); |
589 } | 588 } |
590 } | 589 } |
OLD | NEW |