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

Unified Diff: runtime/bin/file.dart

Issue 9034005: Change the behavior of open on files to not truncate by default (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comment.s Created 8 years, 12 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698