| 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 class FileSystemEntityType { | 7 class FileSystemEntityType { |
| 8 static const FILE = const FileSystemEntityType._internal(0); | 8 static const FILE = const FileSystemEntityType._internal(0); |
| 9 static const DIRECTORY = const FileSystemEntityType._internal(1); | 9 static const DIRECTORY = const FileSystemEntityType._internal(1); |
| 10 static const LINK = const FileSystemEntityType._internal(2); | 10 static const LINK = const FileSystemEntityType._internal(2); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 * | 309 * |
| 310 * If [recursive] is true, the [FileSystemEntity] is deleted even if the type | 310 * If [recursive] is true, the [FileSystemEntity] is deleted even if the type |
| 311 * of the [FileSystemEntity] doesn't match the content of the file system. | 311 * of the [FileSystemEntity] doesn't match the content of the file system. |
| 312 * This behavior allows [delete] to be used to unconditionally delete any file | 312 * This behavior allows [delete] to be used to unconditionally delete any file |
| 313 * system object. | 313 * system object. |
| 314 * | 314 * |
| 315 * Returns a [:Future<FileSystemEntity>:] that completes with this | 315 * Returns a [:Future<FileSystemEntity>:] that completes with this |
| 316 * [FileSystemEntity] when the deletion is done. If the [FileSystemEntity] | 316 * [FileSystemEntity] when the deletion is done. If the [FileSystemEntity] |
| 317 * cannot be deleted, the future completes with an exception. | 317 * cannot be deleted, the future completes with an exception. |
| 318 */ | 318 */ |
| 319 Future<FileSystemEntity> delete({recursive: false}) | 319 Future<FileSystemEntity> delete({bool recursive: false}) |
| 320 => _delete(recursive: recursive); | 320 => _delete(recursive: recursive); |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * Synchronously deletes this [FileSystemEntity]. | 323 * Synchronously deletes this [FileSystemEntity]. |
| 324 * | 324 * |
| 325 * If the [FileSystemEntity] is a directory, and if [recursive] is false, | 325 * If the [FileSystemEntity] is a directory, and if [recursive] is false, |
| 326 * the directory must be empty. Otherwise, if [recursive] is true, the | 326 * the directory must be empty. Otherwise, if [recursive] is true, the |
| 327 * directory and all sub-directories and files in the directories are | 327 * directory and all sub-directories and files in the directories are |
| 328 * deleted. Links are not followed when deleting recursively. Only the link | 328 * deleted. Links are not followed when deleting recursively. Only the link |
| 329 * is deleted, not its target. | 329 * is deleted, not its target. |
| 330 * | 330 * |
| 331 * If [recursive] is true, the [FileSystemEntity] is deleted even if the type | 331 * If [recursive] is true, the [FileSystemEntity] is deleted even if the type |
| 332 * of the [FileSystemEntity] doesn't match the content of the file system. | 332 * of the [FileSystemEntity] doesn't match the content of the file system. |
| 333 * This behavior allows [deleteSync] to be used to unconditionally delete any | 333 * This behavior allows [deleteSync] to be used to unconditionally delete any |
| 334 * file system object. | 334 * file system object. |
| 335 * | 335 * |
| 336 * Throws an exception if the [FileSystemEntity] cannot be deleted. | 336 * Throws an exception if the [FileSystemEntity] cannot be deleted. |
| 337 */ | 337 */ |
| 338 void deleteSync({recursive: false}) | 338 void deleteSync({bool recursive: false}) |
| 339 => _deleteSync(recursive: recursive); | 339 => _deleteSync(recursive: recursive); |
| 340 | 340 |
| 341 | 341 |
| 342 /** | 342 /** |
| 343 * Start watch the [FileSystemEntity] for changes. | 343 * Start watch the [FileSystemEntity] for changes. |
| 344 * | 344 * |
| 345 * The implementation uses platform-depending event-based APIs for receiving | 345 * The implementation uses platform-depending event-based APIs for receiving |
| 346 * file-system notifixations, thus behvaiour depends on the platform. | 346 * file-system notifixations, thus behvaiour depends on the platform. |
| 347 * | 347 * |
| 348 * * `Windows`: Uses `ReadDirectoryChangesW`. The implementation supports | 348 * * `Windows`: Uses `ReadDirectoryChangesW`. The implementation supports |
| 349 * only watching dirctories but supports recursive watching. | 349 * only watching dirctories but supports recursive watching. |
| 350 * * `Linux`: Uses `inotify`. The implementation supports watching both | 350 * * `Linux`: Uses `inotify`. The implementation supports watching both |
| 351 * files and dirctories, but doesn't support recursive watching. | 351 * files and dirctories, but doesn't support recursive watching. |
| 352 * * `Mac OS`: Uses `FSEvents`. The implementation supports watching both | 352 * * `Mac OS`: Uses `FSEvents`. The implementation supports watching both |
| 353 * files and dirctories, and also recursive watching. Note that FSEvents | 353 * files and dirctories, and also recursive watching. Note that FSEvents |
| 354 * always use recursion internally, so when disabled, some events are | 354 * always use recursion internally, so when disabled, some events are |
| 355 * ignored. | 355 * ignored. |
| 356 * | 356 * |
| 357 * The system will start listen for events once the returned [Stream] is | 357 * The system will start listen for events once the returned [Stream] is |
| 358 * being listened to, not when the call to [watch] is issued. Note that the | 358 * being listened to, not when the call to [watch] is issued. Note that the |
| 359 * returned [Stream] is endless. To stop the [Stream], simply cancel the | 359 * returned [Stream] is endless. To stop the [Stream], simply cancel the |
| 360 * subscription. | 360 * subscription. |
| 361 */ | 361 */ |
| 362 Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, | 362 Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, |
| 363 bool recursive: false}) | 363 bool recursive: false}) |
| 364 => new _FileSystemWatcher(_trimTrailingPathSeparators(path), | 364 => new _FileSystemWatcher(_trimTrailingPathSeparators(path), |
| 365 events, | 365 events, |
| 366 recursive).stream; | 366 recursive).stream; |
| 367 | 367 |
| 368 Future<FileSystemEntity> _delete({recursive: false}); | 368 Future<FileSystemEntity> _delete({bool recursive: false}); |
| 369 void _deleteSync({recursive: false}); | 369 void _deleteSync({bool recursive: false}); |
| 370 | 370 |
| 371 /** | 371 /** |
| 372 * Checks whether two paths refer to the same object in the | 372 * Checks whether two paths refer to the same object in the |
| 373 * file system. Returns a [:Future<bool>:] that completes with the result. | 373 * file system. Returns a [:Future<bool>:] that completes with the result. |
| 374 * | 374 * |
| 375 * Comparing a link to its target returns false, as does comparing two links | 375 * Comparing a link to its target returns false, as does comparing two links |
| 376 * that point to the same target. To check the target of a link, use | 376 * that point to the same target. To check the target of a link, use |
| 377 * Link.target explicitly to fetch it. Directory links appearing | 377 * Link.target explicitly to fetch it. Directory links appearing |
| 378 * inside a path are followed, though, to find the file system object. | 378 * inside a path are followed, though, to find the file system object. |
| 379 * | 379 * |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 | 663 |
| 664 | 664 |
| 665 abstract class _FileSystemWatcher { | 665 abstract class _FileSystemWatcher { |
| 666 external factory _FileSystemWatcher(String path, int events, bool recursive); | 666 external factory _FileSystemWatcher(String path, int events, bool recursive); |
| 667 external static bool get isSupported; | 667 external static bool get isSupported; |
| 668 | 668 |
| 669 Stream<FileSystemEvent> get stream; | 669 Stream<FileSystemEvent> get stream; |
| 670 } | 670 } |
| OLD | NEW |