| 1 | /* ============================================================================= |
|---|
| 2 | FILE: UKFileWatcher.h |
|---|
| 3 | PROJECT: Filie |
|---|
| 4 | |
|---|
| 5 | COPYRIGHT: (c) 2005 M. Uli Kusterer, all rights reserved. |
|---|
| 6 | |
|---|
| 7 | AUTHORS: M. Uli Kusterer - UK |
|---|
| 8 | |
|---|
| 9 | LICENSES: MIT License |
|---|
| 10 | |
|---|
| 11 | REVISIONS: |
|---|
| 12 | 2006-03-13 UK Moved notification constants to .m file. |
|---|
| 13 | 2005-02-25 UK Created. |
|---|
| 14 | ========================================================================== */ |
|---|
| 15 | |
|---|
| 16 | /* |
|---|
| 17 | This is a protocol that file change notification classes should adopt. |
|---|
| 18 | That way, no matter whether you use Carbon's FNNotify/FNSubscribe, BSD's |
|---|
| 19 | kqueue or whatever, the object being notified can react to change |
|---|
| 20 | notifications the same way, and you can easily swap one out for the other |
|---|
| 21 | to cater to different OS versions, target volumes etc. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | // ----------------------------------------------------------------------------- |
|---|
| 25 | // Protocol: |
|---|
| 26 | // ----------------------------------------------------------------------------- |
|---|
| 27 | |
|---|
| 28 | @protocol UKFileWatcher |
|---|
| 29 | |
|---|
| 30 | // +(id) sharedFileWatcher; // Singleton accessor. Not officially part of the protocol, but use this name if you provide a singleton. |
|---|
| 31 | |
|---|
| 32 | -(void) addPath: (NSString*)path; |
|---|
| 33 | -(void) removePath: (NSString*)path; |
|---|
| 34 | |
|---|
| 35 | -(id) delegate; |
|---|
| 36 | -(void) setDelegate: (id)newDelegate; |
|---|
| 37 | |
|---|
| 38 | @end |
|---|
| 39 | |
|---|
| 40 | // ----------------------------------------------------------------------------- |
|---|
| 41 | // Methods delegates need to provide: |
|---|
| 42 | // ----------------------------------------------------------------------------- |
|---|
| 43 | |
|---|
| 44 | @interface NSObject (UKFileWatcherDelegate) |
|---|
| 45 | |
|---|
| 46 | -(void) watcher: (id<UKFileWatcher>)kq receivedNotification: (NSString*)nm forPath: (NSString*)fpath; |
|---|
| 47 | |
|---|
| 48 | @end |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | // Notifications this sends: |
|---|
| 52 | /* object = the file watcher object |
|---|
| 53 | userInfo.path = file path watched |
|---|
| 54 | These notifications are sent via the NSWorkspace notification center */ |
|---|
| 55 | extern NSString* UKFileWatcherRenameNotification; |
|---|
| 56 | extern NSString* UKFileWatcherWriteNotification; |
|---|
| 57 | extern NSString* UKFileWatcherDeleteNotification; |
|---|
| 58 | extern NSString* UKFileWatcherAttributeChangeNotification; |
|---|
| 59 | extern NSString* UKFileWatcherSizeIncreaseNotification; |
|---|
| 60 | extern NSString* UKFileWatcherLinkCountChangeNotification; |
|---|
| 61 | extern NSString* UKFileWatcherAccessRevocationNotification; |
|---|