Index: runtime/bin/file.dart |
diff --git a/runtime/bin/file.dart b/runtime/bin/file.dart |
index 3ad0ec7186899c101a08adc492e959edb1135415..4fd8bbbfcd26655c4af433a1a671a99b4c4bcdbb 100644 |
--- a/runtime/bin/file.dart |
+++ b/runtime/bin/file.dart |
@@ -2,6 +2,18 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
+ |
+/** |
+ * FileMode describes the modes in which a file can be opened. |
+ */ |
+class FileMode { |
+ static final READ = const FileMode(0); |
+ static final WRITE = const FileMode(1); |
+ static final APPEND = const FileMode(2); |
+ const FileMode(int this.mode); |
+ final int mode; |
+} |
+ |
interface File default _File { |
/** |
* Create a File object. |
@@ -49,19 +61,48 @@ interface File default _File { |
/** |
* Open the file for random access operations. When the file is |
- * opened the openHandler is called with the resulting |
+ * opened the [openHandler] is called with the resulting |
* RandomAccessFile. RandomAccessFiles must be closed using the |
- * close method. By default writable is false. |
- */ |
- void open([bool writable]); |
+ * [close] method. If the file cannot be opened the [errorHandler] |
+ * is called. |
+ * |
+ * Files can be opened in three modes: |
+ * |
+ * FileMode.READ: open the file for reading. If the file does not |
+ * exist the [errorHandler] is called. |
+ * |
+ * FileMode.WRITE: open the file for both reading and writing and |
+ * truncate the file to length zero. If the file does not exist the |
+ * file is created. |
+ * |
+ * FileMode.APPEND: same as FileMode.WRITE except that the file is |
+ * not truncated. |
+ * |
+ * By default mode is FileMode.READ. |
+ */ |
+ void open([FileMode mode]); |
/** |
* Synchronously open the file for random access operations. The |
* result is a RandomAccessFile on which random access operations |
* can be performed. Opened RandomAccessFiles must be closed using |
- * the close method. By default writable is false. |
- */ |
- RandomAccessFile openSync([bool writable]); |
+ * the [close] method. |
+ * |
+ * Files can be opened in three modes: |
+ * |
+ * FileMode.READ: open the file for reading. If the file does not |
+ * exist the [errorHandler] is called. |
+ * |
+ * FileMode.WRITE: open the file for both reading and writing and |
+ * truncate the file to length zero. If the file does not exist the |
+ * file is created. |
+ * |
+ * FileMode.APPEND: same as FileMode.WRITE except that the file is |
+ * not truncated. |
+ * |
+ * By default mode is FileMode.READ. |
+ */ |
+ RandomAccessFile openSync([FileMode mode]); |
/** |
* Get the canonical full path corresponding to the file name. The |