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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 static const int MOVE = 1 << 3; | 651 static const int MOVE = 1 << 3; |
652 | 652 |
653 /** | 653 /** |
654 * Bitfield for [FileSystemEntity.watch], for enabling all of [CREATE], | 654 * Bitfield for [FileSystemEntity.watch], for enabling all of [CREATE], |
655 * [MODIFY], [DELETE] and [MOVE]. | 655 * [MODIFY], [DELETE] and [MOVE]. |
656 */ | 656 */ |
657 static const int ALL = CREATE | MODIFY | DELETE | MOVE; | 657 static const int ALL = CREATE | MODIFY | DELETE | MOVE; |
658 | 658 |
659 static const int _MODIFY_ATTRIBUTES = 1 << 4; | 659 static const int _MODIFY_ATTRIBUTES = 1 << 4; |
660 static const int _DELETE_SELF = 1 << 5; | 660 static const int _DELETE_SELF = 1 << 5; |
| 661 static const int _IS_DIR = 1 << 6; |
661 | 662 |
662 /** | 663 /** |
663 * The type of event. See [FileSystemEvent] for a list of events. | 664 * The type of event. See [FileSystemEvent] for a list of events. |
664 */ | 665 */ |
665 final int type; | 666 final int type; |
666 | 667 |
667 /** | 668 /** |
668 * The path that triggered the event. Depending on the platform and the | 669 * The path that triggered the event. Depending on the platform and the |
669 * FileSystemEntity, the path may be relative. | 670 * FileSystemEntity, the path may be relative. |
670 */ | 671 */ |
671 final String path; | 672 final String path; |
672 | 673 |
673 FileSystemEvent._(this.type, this.path); | 674 /** |
| 675 * Is `true` if the event target was a directory. |
| 676 */ |
| 677 final bool isDirectory; |
| 678 |
| 679 FileSystemEvent._(this.type, this.path, this.isDirectory); |
674 } | 680 } |
675 | 681 |
676 | 682 |
677 /** | 683 /** |
678 * File system event for newly created file system objects. | 684 * File system event for newly created file system objects. |
679 */ | 685 */ |
680 class FileSystemCreateEvent extends FileSystemEvent { | 686 class FileSystemCreateEvent extends FileSystemEvent { |
681 FileSystemCreateEvent._(path) | 687 FileSystemCreateEvent._(path, isDirectory) |
682 : super._(FileSystemEvent.CREATE, path); | 688 : super._(FileSystemEvent.CREATE, path, isDirectory); |
683 | 689 |
684 String toString() => "FileSystemCreateEvent('$path')"; | 690 String toString() => "FileSystemCreateEvent('$path')"; |
685 } | 691 } |
686 | 692 |
687 | 693 |
688 /** | 694 /** |
689 * File system event for modifications of file system objects. | 695 * File system event for modifications of file system objects. |
690 */ | 696 */ |
691 class FileSystemModifyEvent extends FileSystemEvent { | 697 class FileSystemModifyEvent extends FileSystemEvent { |
692 /** | 698 /** |
693 * If the content was changed and not only the attributes, [contentChanged] | 699 * If the content was changed and not only the attributes, [contentChanged] |
694 * is `true`. | 700 * is `true`. |
695 */ | 701 */ |
696 final bool contentChanged; | 702 final bool contentChanged; |
697 | 703 |
698 FileSystemModifyEvent._(path, this.contentChanged) | 704 FileSystemModifyEvent._(path, isDirectory, this.contentChanged) |
699 : super._(FileSystemEvent.MODIFY, path); | 705 : super._(FileSystemEvent.MODIFY, path, isDirectory); |
700 | 706 |
701 String toString() => | 707 String toString() => |
702 "FileSystemModifyEvent('$path', contentChanged=$contentChanged)"; | 708 "FileSystemModifyEvent('$path', contentChanged=$contentChanged)"; |
703 } | 709 } |
704 | 710 |
705 | 711 |
706 /** | 712 /** |
707 * File system event for deletion of file system objects. | 713 * File system event for deletion of file system objects. |
708 */ | 714 */ |
709 class FileSystemDeleteEvent extends FileSystemEvent { | 715 class FileSystemDeleteEvent extends FileSystemEvent { |
710 FileSystemDeleteEvent._(path) | 716 FileSystemDeleteEvent._(path, isDirectory) |
711 : super._(FileSystemEvent.DELETE, path); | 717 : super._(FileSystemEvent.DELETE, path, isDirectory); |
712 | 718 |
713 String toString() => "FileSystemDeleteEvent('$path')"; | 719 String toString() => "FileSystemDeleteEvent('$path')"; |
714 } | 720 } |
715 | 721 |
716 | 722 |
717 /** | 723 /** |
718 * File system event for moving of file system objects. | 724 * File system event for moving of file system objects. |
719 */ | 725 */ |
720 class FileSystemMoveEvent extends FileSystemEvent { | 726 class FileSystemMoveEvent extends FileSystemEvent { |
721 /** | 727 /** |
722 * If the underlaying implementation is able to identify the destination of | 728 * If the underlaying implementation is able to identify the destination of |
723 * the moved file, [destination] will be set. Otherwise, it will be `null`. | 729 * the moved file, [destination] will be set. Otherwise, it will be `null`. |
724 */ | 730 */ |
725 final String destination; | 731 final String destination; |
726 | 732 |
727 FileSystemMoveEvent._(path, this.destination) | 733 FileSystemMoveEvent._(path, isDirectory, this.destination) |
728 : super._(FileSystemEvent.MOVE, path); | 734 : super._(FileSystemEvent.MOVE, path, isDirectory); |
729 | 735 |
730 String toString() { | 736 String toString() { |
731 var buffer = new StringBuffer(); | 737 var buffer = new StringBuffer(); |
732 buffer.write("FileSystemMoveEvent('$path'"); | 738 buffer.write("FileSystemMoveEvent('$path'"); |
733 if (destination != null) buffer.write(", '$destination'"); | 739 if (destination != null) buffer.write(", '$destination'"); |
734 buffer.write(')'); | 740 buffer.write(')'); |
735 return buffer.toString(); | 741 return buffer.toString(); |
736 } | 742 } |
737 } | 743 } |
738 | 744 |
739 | 745 |
740 abstract class _FileSystemWatcher { | 746 abstract class _FileSystemWatcher { |
741 external factory _FileSystemWatcher(String path, int events, bool recursive); | 747 external factory _FileSystemWatcher(String path, int events, bool recursive); |
742 external static bool get isSupported; | 748 external static bool get isSupported; |
743 | 749 |
744 Stream<FileSystemEvent> get stream; | 750 Stream<FileSystemEvent> get stream; |
745 } | 751 } |
OLD | NEW |