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

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

Issue 11316102: Add utility methods to write the contents of a file as one operation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | sdk/lib/io/file_impl.dart » ('j') | sdk/lib/io/file_impl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 5
6 /** 6 /**
7 * FileMode describes the modes in which a file can be opened. 7 * FileMode describes the modes in which a file can be opened.
8 */ 8 */
9 class FileMode { 9 class FileMode {
10 static const READ = const FileMode._internal(0); 10 static const READ = const FileMode._internal(0);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 */ 207 */
208 Future<List<String>> readAsLines([Encoding encoding = Encoding.UTF_8]); 208 Future<List<String>> readAsLines([Encoding encoding = Encoding.UTF_8]);
209 209
210 /** 210 /**
211 * Synchronously read the entire file contents as lines of text 211 * Synchronously read the entire file contents as lines of text
212 * using the given [encoding]. 212 * using the given [encoding].
213 */ 213 */
214 List<String> readAsLinesSync([Encoding encoding = Encoding.UTF_8]); 214 List<String> readAsLinesSync([Encoding encoding = Encoding.UTF_8]);
215 215
216 /** 216 /**
217 * Write a list of bytes to a file.
218 *
219 * Opens the file, writes the list of bytes to it, and closes the file.
220 * Returns a [:Future<File>:] that completes with this [File] object once
221 * the entire operation has completed.
222 *
223 * By default [writeAsBytes] creates the file for writing and truncates the
224 * file if it already exists. In order to append the bytes to an existing
225 * file pass [:FileMode.APPEND:] as the optional mode parameter.
226 */
227 Future<File> writeAsBytes(List<int> bytes, [FileMode mode = FileMode.WRITE]);
228
229 /**
230 * Synchronously write a list of bytes to a file.
231 *
232 * Opens the file, writes the list of bytes to it and closses the file.
233 *
234 * By default [writeAsBytesSync] creates the file for writing and truncates
235 * the file if it already exists. In order to append the bytes to an existing
236 * file pass [:FileMode.APPEND:] as the optional mode parameter.
237 */
238 void writeAsBytesSync(List<int> bytes, [FileMode mode = FileMode.WRITE]);
239
240 /**
241 * Write a string to a file.
242 *
243 * Opens the file, writes the string in the given encoding, and closes the
244 * file. Returns a [:Future<File>:] that completes with this [File] object
245 * once the entire operation has completed.
246 *
247 * By default [writeAsString] creates the file for writing and truncates the
248 * file if it already exists. In order to append the bytes to an existing
249 * file pass [:FileMode.APPEND:] as the optional mode parameter.
250 */
251 Future<File> writeAsString(String contents,
252 [Encoding encoding = Encoding.UTF_8,
253 FileMode mode = FileMode.WRITE]);
254
255 /**
256 * Synchronously write a string to a file.
257 *
258 * Opens the file, writes the string in the given encoding, and closes the
259 * file.
260 *
261 * By default [writeAsStringSync] creates the file for writing and
262 * truncates the file if it already exists. In order to append the bytes
263 * to an existing file pass [:FileMode.APPEND:] as the optional mode
264 * parameter.
265 */
266 void writeAsStringSync(String contents,
267 [Encoding encoding = Encoding.UTF_8,
268 FileMode mode = FileMode.WRITE]);
269
270 /**
217 * Get the name of the file. 271 * Get the name of the file.
218 */ 272 */
219 String get name; 273 String get name;
220 } 274 }
221 275
222 276
223 /** 277 /**
224 * [RandomAccessFile] provides random access to the data in a 278 * [RandomAccessFile] provides random access to the data in a
225 * file. [RandomAccessFile] objects are obtained by calling the 279 * file. [RandomAccessFile] objects are obtained by calling the
226 * [:open:] method on a [File] object. 280 * [:open:] method on a [File] object.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 sb.add(" ($osError)"); 434 sb.add(" ($osError)");
381 } 435 }
382 } else if (osError != null) { 436 } else if (osError != null) {
383 sb.add(": osError"); 437 sb.add(": osError");
384 } 438 }
385 return sb.toString(); 439 return sb.toString();
386 } 440 }
387 final String message; 441 final String message;
388 final OSError osError; 442 final OSError osError;
389 } 443 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/file_impl.dart » ('j') | sdk/lib/io/file_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698