| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 344    * | 344    * | 
| 345    * The implementation uses platform-dependent event-based APIs for receiving | 345    * The implementation uses platform-dependent event-based APIs for receiving | 
| 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    *     Note: events happened slightly before calling [watch], may be part of | 
|  | 355    *     the returned stream, on Mac OS. | 
| 354    * | 356    * | 
| 355    * The system will start listening for events once the returned [Stream] is | 357    * The system will start listening for events once the returned [Stream] is | 
| 356    * being listened to, not when the call to [watch] is issued. | 358    * being listened to, not when the call to [watch] is issued. | 
| 357    * | 359    * | 
| 358    * Note that the returned [Stream] is endless, unless: | 360    * Note: that the returned [Stream] is endless, unless: | 
| 359    * | 361    * | 
| 360    *   * The [Stream] is canceled, e.g. by calling `cancel` on the | 362    *   * The [Stream] is canceled, e.g. by calling `cancel` on the | 
| 361    *      [StreamSubscription]. | 363    *      [StreamSubscription]. | 
| 362    *   * The [FileSystemEntity] being watches, is deleted. | 364    *   * The [FileSystemEntity] being watches, is deleted. | 
|  | 365    * | 
|  | 366    * Use `events` to specify what events to listen for. The constants in | 
|  | 367    * [FileSystemEvent] can be or'ed together to mix events. Default is | 
|  | 368    * [FileSystemEvent.ALL]. | 
| 363    */ | 369    */ | 
| 364   Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, | 370   Stream<FileSystemEvent> watch({int events: FileSystemEvent.ALL, | 
| 365                                  bool recursive: false}) | 371                                  bool recursive: false}) | 
| 366      => new _FileSystemWatcher(_trimTrailingPathSeparators(path), | 372      => new _FileSystemWatcher(_trimTrailingPathSeparators(path), | 
| 367                                events, | 373                                events, | 
| 368                                recursive).stream; | 374                                recursive).stream; | 
| 369 | 375 | 
| 370   Future<FileSystemEntity> _delete({bool recursive: false}); | 376   Future<FileSystemEntity> _delete({bool recursive: false}); | 
| 371   void _deleteSync({bool recursive: false}); | 377   void _deleteSync({bool recursive: false}); | 
| 372 | 378 | 
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 611       while (path.length > 1 && path.endsWith(Platform.pathSeparator)) { | 617       while (path.length > 1 && path.endsWith(Platform.pathSeparator)) { | 
| 612         path = path.substring(0, path.length - 1); | 618         path = path.substring(0, path.length - 1); | 
| 613       } | 619       } | 
| 614     } | 620     } | 
| 615     return path; | 621     return path; | 
| 616   } | 622   } | 
| 617 } | 623 } | 
| 618 | 624 | 
| 619 | 625 | 
| 620 /** | 626 /** | 
| 621  * Base event class emitted by FileSystemWatcher. | 627  * Base event class emitted by [FileSystemEntity.watch]. | 
| 622  */ | 628  */ | 
| 623 class FileSystemEvent { | 629 class FileSystemEvent { | 
|  | 630   /** | 
|  | 631    * Bitfield for [FileSystemEntity.watch], to enable [FileSystemCreateEvent]s. | 
|  | 632    */ | 
| 624   static const int CREATE = 1 << 0; | 633   static const int CREATE = 1 << 0; | 
|  | 634 | 
|  | 635   /** | 
|  | 636    * Bitfield for [FileSystemEntity.watch], to enable [FileSystemModifyEvent]s. | 
|  | 637    */ | 
| 625   static const int MODIFY = 1 << 1; | 638   static const int MODIFY = 1 << 1; | 
|  | 639 | 
|  | 640   /** | 
|  | 641    * Bitfield for [FileSystemEntity.watch], to enable [FileSystemDeleteEvent]s. | 
|  | 642    */ | 
| 626   static const int DELETE = 1 << 2; | 643   static const int DELETE = 1 << 2; | 
|  | 644 | 
|  | 645   /** | 
|  | 646    * Bitfield for [FileSystemEntity.watch], to enable [FileSystemMoveEvent]s. | 
|  | 647    */ | 
| 627   static const int MOVE = 1 << 3; | 648   static const int MOVE = 1 << 3; | 
|  | 649 | 
|  | 650   /** | 
|  | 651    * Bitfield for [FileSystemEntity.watch], for enabling all of [CREATE], | 
|  | 652    * [MODIFY], [DELETE] and [MOVE]. | 
|  | 653    */ | 
| 628   static const int ALL = CREATE | MODIFY | DELETE | MOVE; | 654   static const int ALL = CREATE | MODIFY | DELETE | MOVE; | 
| 629 | 655 | 
| 630   static const int _MODIFY_ATTRIBUTES = 1 << 4; | 656   static const int _MODIFY_ATTRIBUTES = 1 << 4; | 
| 631   static const int _DELETE_SELF = 1 << 5; | 657   static const int _DELETE_SELF = 1 << 5; | 
| 632 | 658 | 
| 633   /** | 659   /** | 
| 634    * The type of event. See [FileSystemEvent] for a list of events. | 660    * The type of event. See [FileSystemEvent] for a list of events. | 
| 635    */ | 661    */ | 
| 636   final int type; | 662   final int type; | 
| 637 | 663 | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 707   } | 733   } | 
| 708 } | 734 } | 
| 709 | 735 | 
| 710 | 736 | 
| 711 abstract class _FileSystemWatcher { | 737 abstract class _FileSystemWatcher { | 
| 712   external factory _FileSystemWatcher(String path, int events, bool recursive); | 738   external factory _FileSystemWatcher(String path, int events, bool recursive); | 
| 713   external static bool get isSupported; | 739   external static bool get isSupported; | 
| 714 | 740 | 
| 715   Stream<FileSystemEvent> get stream; | 741   Stream<FileSystemEvent> get stream; | 
| 716 } | 742 } | 
| OLD | NEW | 
|---|