OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * The modes in which a File can be opened. | 8 * The modes in which a File can be opened. |
9 */ | 9 */ |
10 class FileMode { | 10 class FileMode { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 * | 153 * |
154 * void main() { | 154 * void main() { |
155 * final filename = 'file.txt'; | 155 * final filename = 'file.txt'; |
156 * new File(filename).writeAsString('some content') | 156 * new File(filename).writeAsString('some content') |
157 * .then((File file) { | 157 * .then((File file) { |
158 * // Do something with the file. | 158 * // Do something with the file. |
159 * }); | 159 * }); |
160 * } | 160 * } |
161 * | 161 * |
162 * You can also write to a file using a [Stream]. Open the file with | 162 * You can also write to a file using a [Stream]. Open the file with |
163 * [openWrite], which returns a stream to which you can write data. | 163 * [openWrite], which returns an [IOSink] to which you can write data. |
164 * Be sure to close the file with the [close] method. | 164 * Be sure to close the sink with the [IOSink.close] method. |
165 * | 165 * |
166 * import 'dart:io'; | 166 * import 'dart:io'; |
167 * | 167 * |
168 * void main() { | 168 * void main() { |
169 * var file = new File('file.txt'); | 169 * var file = new File('file.txt'); |
170 * var sink = file.openWrite(); | 170 * var sink = file.openWrite(); |
171 * sink.write('FILE ACCESSED ${new DateTime.now()}\n'); | 171 * sink.write('FILE ACCESSED ${new DateTime.now()}\n'); |
172 * | 172 * |
173 * // Close the IOSink to free system resources. | 173 * // Close the IOSink to free system resources. |
174 * sink.close(); | 174 * sink.close(); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 * if the information is available. Blocks until the information can be returned | 336 * if the information is available. Blocks until the information can be returned |
337 * or it is determined that the information is not available. | 337 * or it is determined that the information is not available. |
338 * | 338 * |
339 * Throws a [FileSystemException] if the operation fails. | 339 * Throws a [FileSystemException] if the operation fails. |
340 */ | 340 */ |
341 DateTime lastAccessedSync(); | 341 DateTime lastAccessedSync(); |
342 | 342 |
343 /** | 343 /** |
344 * Modifies the time the file was last accessed. | 344 * Modifies the time the file was last accessed. |
345 * | 345 * |
346 * Throws a [FilsSystemException] if the time cannot be set. | 346 * Throws a [FileSystemException] if the time cannot be set. |
347 */ | 347 */ |
348 Future setLastAccessed(DateTime time); | 348 Future setLastAccessed(DateTime time); |
349 | 349 |
350 /** | 350 /** |
351 * Synchronously modifies the time the file was last accessed. | 351 * Synchronously modifies the time the file was last accessed. |
352 * | 352 * |
353 * Throws a [FilsSystemException] if the time cannot be set. | 353 * Throws a [FileSystemException] if the time cannot be set. |
354 */ | 354 */ |
355 void setLastAccessedSync(DateTime time); | 355 void setLastAccessedSync(DateTime time); |
356 | 356 |
357 /** | 357 /** |
358 * Get the last-modified time of the file. | 358 * Get the last-modified time of the file. |
359 * | 359 * |
360 * Returns the date and time when the file was last modified, if the | 360 * Returns the date and time when the file was last modified, if the |
361 * information is available. | 361 * information is available. |
362 * | 362 * |
363 * Throws a [FileSystemException] if the operation fails. | 363 * Throws a [FileSystemException] if the operation fails. |
364 */ | 364 */ |
365 Future<DateTime> lastModified(); | 365 Future<DateTime> lastModified(); |
366 | 366 |
367 /** | 367 /** |
368 * Get the last-modified time of the file. | 368 * Get the last-modified time of the file. |
369 * | 369 * |
370 * Returns the date and time when the file was last modified, | 370 * Returns the date and time when the file was last modified, |
371 * if the information is available. Blocks until the information can be returned | 371 * if the information is available. Blocks until the information can be returned |
372 * or it is determined that the information is not available. | 372 * or it is determined that the information is not available. |
373 * | 373 * |
374 * Throws a [FileSystemException] if the operation fails. | 374 * Throws a [FileSystemException] if the operation fails. |
375 */ | 375 */ |
376 DateTime lastModifiedSync(); | 376 DateTime lastModifiedSync(); |
377 | 377 |
378 /** | 378 /** |
379 * Modifies the time the file was last modified. | 379 * Modifies the time the file was last modified. |
380 * | 380 * |
381 * Throws a [FilsSystemException] if the time cannot be set. | 381 * Throws a [FileSystemException] if the time cannot be set. |
382 */ | 382 */ |
383 Future setLastModified(DateTime time); | 383 Future setLastModified(DateTime time); |
384 | 384 |
385 /** | 385 /** |
386 * Synchronously modifies the time the file was last modified. | 386 * Synchronously modifies the time the file was last modified. |
387 * | 387 * |
388 * If the attributes cannot be set, throws a [FileSystemException]. | 388 * If the attributes cannot be set, throws a [FileSystemException]. |
389 */ | 389 */ |
390 void setLastModifiedSync(DateTime time); | 390 void setLastModifiedSync(DateTime time); |
391 | 391 |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 sb.write(": $osError"); | 949 sb.write(": $osError"); |
950 if (path != null) { | 950 if (path != null) { |
951 sb.write(", path = '$path'"); | 951 sb.write(", path = '$path'"); |
952 } | 952 } |
953 } else if (path != null) { | 953 } else if (path != null) { |
954 sb.write(": $path"); | 954 sb.write(": $path"); |
955 } | 955 } |
956 return sb.toString(); | 956 return sb.toString(); |
957 } | 957 } |
958 } | 958 } |
OLD | NEW |