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

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

Issue 12314153: dart:io | Rename File.name to File.path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove stray line break. Created 7 years, 9 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
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 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 {
(...skipping 12 matching lines...) Expand all
23 * 23 *
24 * * Use streaming: read the contents of the file from the [Stream] 24 * * Use streaming: read the contents of the file from the [Stream]
25 * this.[openRead]() and write to the file by writing to the [IOSink] 25 * this.[openRead]() and write to the file by writing to the [IOSink]
26 * this.[openWrite](). 26 * this.[openWrite]().
27 * * Open the file for random access operations using [open]. 27 * * Open the file for random access operations using [open].
28 */ 28 */
29 abstract class File extends FileSystemEntity { 29 abstract class File extends FileSystemEntity {
30 /** 30 /**
31 * Create a File object. 31 * Create a File object.
32 */ 32 */
33 factory File(String name) => new _File(name); 33 factory File(String path) => new _File(path);
34 34
35 /** 35 /**
36 * Create a File object from a Path object. 36 * Create a File object from a Path object.
37 */ 37 */
38 factory File.fromPath(Path path) => new _File.fromPath(path); 38 factory File.fromPath(Path path) => new _File.fromPath(path);
39 39
40 /** 40 /**
41 * Check if the file exists. Returns a 41 * Check if the file exists. Returns a
42 * [:Future<bool>:] that completes when the answer is known. 42 * [:Future<bool>:] that completes when the answer is known.
43 */ 43 */
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 * Synchronously open the file for random access operations. The 136 * Synchronously open the file for random access operations. The
137 * result is a [RandomAccessFile] on which random access operations 137 * result is a [RandomAccessFile] on which random access operations
138 * can be performed. Opened [RandomAccessFile]s must be closed using 138 * can be performed. Opened [RandomAccessFile]s must be closed using
139 * the [RandomAccessFile.close] method. 139 * the [RandomAccessFile.close] method.
140 * 140 *
141 * See [open] for information on the [mode] argument. 141 * See [open] for information on the [mode] argument.
142 */ 142 */
143 RandomAccessFile openSync([FileMode mode = FileMode.READ]); 143 RandomAccessFile openSync([FileMode mode = FileMode.READ]);
144 144
145 /** 145 /**
146 * Get the canonical full path corresponding to the file name. 146 * Get the canonical full path corresponding to the file path.
147 * Returns a [:Future<String>:] that completes with the path. 147 * Returns a [:Future<String>:] that completes with the path.
148 */ 148 */
149 Future<String> fullPath(); 149 Future<String> fullPath();
150 150
151 /** 151 /**
152 * Synchronously get the canonical full path corresponding to the file name. 152 * Synchronously get the canonical full path corresponding to the file path.
153 */ 153 */
154 String fullPathSync(); 154 String fullPathSync();
155 155
156 /** 156 /**
157 * Create a new independent [Stream](../dart_async/Stream.html) for the 157 * Create a new independent [Stream](../dart_async/Stream.html) for the
158 * contents of this file. 158 * contents of this file.
159 * 159 *
160 * In order to make sure that system resources are freed, the stream 160 * In order to make sure that system resources are freed, the stream
161 * must be read to completion or the subscription on the stream must 161 * must be read to completion or the subscription on the stream must
162 * be cancelled. 162 * be cancelled.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 * By default [writeAsStringSync] creates the file for writing and 267 * By default [writeAsStringSync] creates the file for writing and
268 * truncates the file if it already exists. In order to append the bytes 268 * truncates the file if it already exists. In order to append the bytes
269 * to an existing file, pass [FileMode.APPEND] as the optional mode 269 * to an existing file, pass [FileMode.APPEND] as the optional mode
270 * parameter. 270 * parameter.
271 */ 271 */
272 void writeAsStringSync(String contents, 272 void writeAsStringSync(String contents,
273 {FileMode mode: FileMode.WRITE, 273 {FileMode mode: FileMode.WRITE,
274 Encoding encoding: Encoding.UTF_8}); 274 Encoding encoding: Encoding.UTF_8});
275 275
276 /** 276 /**
277 * Get the name of the file. 277 * Get the path of the file.
278 */ 278 */
279 String get name; 279 String get path;
280 } 280 }
281 281
282 282
283 /** 283 /**
284 * [RandomAccessFile] provides random access to the data in a 284 * [RandomAccessFile] provides random access to the data in a
285 * file. [RandomAccessFile] objects are obtained by calling the 285 * file. [RandomAccessFile] objects are obtained by calling the
286 * [:open:] method on a [File] object. 286 * [:open:] method on a [File] object.
287 */ 287 */
288 abstract class RandomAccessFile { 288 abstract class RandomAccessFile {
289 /** 289 /**
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 * Synchronously flushes the contents of the file to disk. 437 * Synchronously flushes the contents of the file to disk.
438 */ 438 */
439 void flushSync(); 439 void flushSync();
440 440
441 /** 441 /**
442 * Returns a human-readable string for this RandomAccessFile instance. 442 * Returns a human-readable string for this RandomAccessFile instance.
443 */ 443 */
444 String toString(); 444 String toString();
445 445
446 /** 446 /**
447 * Gets the name of the file underlying this RandomAccessFile. 447 * Gets the path of the file underlying this RandomAccessFile.
448 */ 448 */
449 String get name; 449 String get path;
450 } 450 }
451 451
452 452
453 class FileIOException implements Exception { 453 class FileIOException implements Exception {
454 const FileIOException([String this.message = "", 454 const FileIOException([String this.message = "",
455 OSError this.osError = null]); 455 OSError this.osError = null]);
456 String toString() { 456 String toString() {
457 StringBuffer sb = new StringBuffer(); 457 StringBuffer sb = new StringBuffer();
458 sb.add("FileIOException"); 458 sb.add("FileIOException");
459 if (!message.isEmpty) { 459 if (!message.isEmpty) {
460 sb.add(": $message"); 460 sb.add(": $message");
461 if (osError != null) { 461 if (osError != null) {
462 sb.add(" ($osError)"); 462 sb.add(" ($osError)");
463 } 463 }
464 } else if (osError != null) { 464 } else if (osError != null) {
465 sb.add(": osError"); 465 sb.add(": osError");
466 } 466 }
467 return sb.toString(); 467 return sb.toString();
468 } 468 }
469 final String message; 469 final String message;
470 final OSError osError; 470 final OSError osError;
471 } 471 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698