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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 * file-system notifications, thus behavior depends on the platform. | 346 * file-system notifications, thus behavior depends on the platform. |
347 * | 347 * |
348 * * `Windows`: Uses `ReadDirectoryChangesW`. The implementation only | 348 * * `Windows`: Uses `ReadDirectoryChangesW`. The implementation only |
349 * supports watching directories. Recursive watching is supported. | 349 * supports watching directories. Recursive watching is supported. |
350 * * `Linux`: Uses `inotify`. The implementation supports watching both | 350 * * `Linux`: Uses `inotify`. The implementation supports watching both |
351 * files and directories. Recursive watching is not supported. | 351 * files and directories. Recursive watching is not supported. |
352 * * `Mac OS`: Uses `FSEvents`. The implementation supports watching both | 352 * * `Mac OS`: Uses `FSEvents`. The implementation supports watching both |
353 * files and directories. Recursive watching is supported. | 353 * files and directories. Recursive watching is supported. |
354 * | 354 * |
355 * The system will start listening for events once the returned [Stream] is | 355 * The system will start listening for events once the returned [Stream] is |
356 * being listened to, not when the call to [watch] is issued. Note that the | 356 * being listened to, not when the call to [watch] is issued. |
357 * returned [Stream] is endless. To stop the [Stream], cancel the subscription
. | 357 * |
| 358 * Note that the returned [Stream] is endless, unless: |
| 359 * |
| 360 * * The [Stream] is canceled, e.g. by calling `cancel` on the |
| 361 * [StreamSubscription]. |
| 362 * * The [FileSystemEntity] being watches, is deleted. |
358 */ | 363 */ |
359 Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, | 364 Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, |
360 bool recursive: false}) | 365 bool recursive: false}) |
361 => new _FileSystemWatcher(_trimTrailingPathSeparators(path), | 366 => new _FileSystemWatcher(_trimTrailingPathSeparators(path), |
362 events, | 367 events, |
363 recursive).stream; | 368 recursive).stream; |
364 | 369 |
365 Future<FileSystemEntity> _delete({bool recursive: false}); | 370 Future<FileSystemEntity> _delete({bool recursive: false}); |
366 void _deleteSync({bool recursive: false}); | 371 void _deleteSync({bool recursive: false}); |
367 | 372 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 * Base event class emitted by FileSystemWatcher. | 621 * Base event class emitted by FileSystemWatcher. |
617 */ | 622 */ |
618 class FileSystemEvent { | 623 class FileSystemEvent { |
619 static const int CREATE = 1 << 0; | 624 static const int CREATE = 1 << 0; |
620 static const int MODIFY = 1 << 1; | 625 static const int MODIFY = 1 << 1; |
621 static const int DELETE = 1 << 2; | 626 static const int DELETE = 1 << 2; |
622 static const int MOVE = 1 << 3; | 627 static const int MOVE = 1 << 3; |
623 static const int ALL = CREATE | MODIFY | DELETE | MOVE; | 628 static const int ALL = CREATE | MODIFY | DELETE | MOVE; |
624 | 629 |
625 static const int _MODIFY_ATTRIBUTES = 1 << 4; | 630 static const int _MODIFY_ATTRIBUTES = 1 << 4; |
| 631 static const int _DELETE_SELF = 1 << 5; |
626 | 632 |
627 /** | 633 /** |
628 * The type of event. See [FileSystemEvent] for a list of events. | 634 * The type of event. See [FileSystemEvent] for a list of events. |
629 */ | 635 */ |
630 final int type; | 636 final int type; |
631 | 637 |
632 /** | 638 /** |
633 * The path that triggered the event. Depending on the platform and the | 639 * The path that triggered the event. Depending on the platform and the |
634 * FileSystemEntity, the path may be relative. | 640 * FileSystemEntity, the path may be relative. |
635 */ | 641 */ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 } | 707 } |
702 } | 708 } |
703 | 709 |
704 | 710 |
705 abstract class _FileSystemWatcher { | 711 abstract class _FileSystemWatcher { |
706 external factory _FileSystemWatcher(String path, int events, bool recursive); | 712 external factory _FileSystemWatcher(String path, int events, bool recursive); |
707 external static bool get isSupported; | 713 external static bool get isSupported; |
708 | 714 |
709 Stream<FileSystemEvent> get stream; | 715 Stream<FileSystemEvent> get stream; |
710 } | 716 } |
OLD | NEW |