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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/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) 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
6 /**
7 * FileMode describes the modes in which a file can be opened.
8 */
9 class FileMode {
10 static final READ = const FileMode(0);
11 static final WRITE = const FileMode(1);
12 static final APPEND = const FileMode(2);
13 const FileMode(int this.mode);
14 final int mode;
15 }
16
5 interface File default _File { 17 interface File default _File {
6 /** 18 /**
7 * Create a File object. 19 * Create a File object.
8 */ 20 */
9 File(String name); 21 File(String name);
10 22
11 /** 23 /**
12 * Check if the file exists. The [existsHandler] is called with the 24 * Check if the file exists. The [existsHandler] is called with the
13 * result when the operation completes. 25 * result when the operation completes.
14 */ 26 */
(...skipping 27 matching lines...) Expand all
42 */ 54 */
43 void delete(); 55 void delete();
44 56
45 /** 57 /**
46 * Synchronously delete the file. 58 * Synchronously delete the file.
47 */ 59 */
48 void deleteSync(); 60 void deleteSync();
49 61
50 /** 62 /**
51 * Open the file for random access operations. When the file is 63 * Open the file for random access operations. When the file is
52 * opened the openHandler is called with the resulting 64 * opened the [openHandler] is called with the resulting
53 * RandomAccessFile. RandomAccessFiles must be closed using the 65 * RandomAccessFile. RandomAccessFiles must be closed using the
54 * close method. By default writable is false. 66 * [close] method. If the file cannot be opened the [errorHandler]
67 * is called.
68 *
69 * Files can be opened in three modes:
70 *
71 * FileMode.READ: open the file for reading. If the file does not
72 * exist the [errorHandler] is called.
73 *
74 * FileMode.WRITE: open the file for both reading and writing and
75 * truncate the file to length zero. If the file does not exist the
76 * file is created.
77 *
78 * FileMode.APPEND: same as FileMode.WRITE except that the file is
79 * not truncated.
80 *
81 * By default mode is FileMode.READ.
55 */ 82 */
56 void open([bool writable]); 83 void open([FileMode mode]);
57 84
58 /** 85 /**
59 * Synchronously open the file for random access operations. The 86 * Synchronously open the file for random access operations. The
60 * result is a RandomAccessFile on which random access operations 87 * result is a RandomAccessFile on which random access operations
61 * can be performed. Opened RandomAccessFiles must be closed using 88 * can be performed. Opened RandomAccessFiles must be closed using
62 * the close method. By default writable is false. 89 * the [close] method.
90 *
91 * Files can be opened in three modes:
92 *
93 * FileMode.READ: open the file for reading. If the file does not
94 * exist the [errorHandler] is called.
95 *
96 * FileMode.WRITE: open the file for both reading and writing and
97 * truncate the file to length zero. If the file does not exist the
98 * file is created.
99 *
100 * FileMode.APPEND: same as FileMode.WRITE except that the file is
101 * not truncated.
102 *
103 * By default mode is FileMode.READ.
63 */ 104 */
64 RandomAccessFile openSync([bool writable]); 105 RandomAccessFile openSync([FileMode mode]);
65 106
66 /** 107 /**
67 * Get the canonical full path corresponding to the file name. The 108 * Get the canonical full path corresponding to the file name. The
68 * [fullPathHandler] is called when the fullPath operation 109 * [fullPathHandler] is called when the fullPath operation
69 * completes. 110 * completes.
70 */ 111 */
71 String fullPath(); 112 String fullPath();
72 113
73 /** 114 /**
74 * Synchronously get the canonical full path corresponding to the file name. 115 * Synchronously get the canonical full path corresponding to the file name.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void set flushHandler(void handler()); 293 void set flushHandler(void handler());
253 void set errorHandler(void handler(String error)); 294 void set errorHandler(void handler(String error));
254 } 295 }
255 296
256 297
257 class FileIOException implements Exception { 298 class FileIOException implements Exception {
258 const FileIOException([String this.message = ""]); 299 const FileIOException([String this.message = ""]);
259 String toString() => "FileIOException: $message"; 300 String toString() => "FileIOException: $message";
260 final String message; 301 final String message;
261 } 302 }
OLDNEW
« 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