Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 85 lines (64 sloc) 3.952 kB
dc5be1c Initial check-in.
uli authored
1 /* =============================================================================
2 FILE: UKKQueue.h
3 PROJECT: Filie
4
5 COPYRIGHT: (c) 2003 M. Uli Kusterer, all rights reserved.
6
7 AUTHORS: M. Uli Kusterer - UK
8
9 LICENSES: MIT License
10
11 REVISIONS:
12 2008-11-07 UK Removed deprecated stuff, more comments.
13 2008-11-05 UK General cleanup, prettier thread handling.
14 2006-03-13 UK Clarified license, streamlined UKFileWatcher stuff,
15 Changed notifications to be useful and turned off by
16 default some deprecated stuff.
17 2003-12-21 UK Created.
18 ========================================================================== */
19
20 // -----------------------------------------------------------------------------
21 // Headers:
22 // -----------------------------------------------------------------------------
23
24 #import <Foundation/Foundation.h>
25 #include <sys/types.h>
26 #include <sys/event.h>
27 #import "UKFileWatcher.h"
28
29
30 // -----------------------------------------------------------------------------
31 // Constants:
32 // -----------------------------------------------------------------------------
33
34 // Flags for notifyingAbout:
35 #define UKKQueueNotifyAboutRename NOTE_RENAME // Item was renamed.
36 #define UKKQueueNotifyAboutWrite NOTE_WRITE // Item contents changed (also folder contents changed).
37 #define UKKQueueNotifyAboutDelete NOTE_DELETE // item was removed.
38 #define UKKQueueNotifyAboutAttributeChange NOTE_ATTRIB // Item attributes changed.
39 #define UKKQueueNotifyAboutSizeIncrease NOTE_EXTEND // Item size increased.
40 #define UKKQueueNotifyAboutLinkCountChanged NOTE_LINK // Item's link count changed.
41 #define UKKQueueNotifyAboutAccessRevocation NOTE_REVOKE // Access to item was revoked.
42
43
44 // -----------------------------------------------------------------------------
45 // UKKQueue:
46 // -----------------------------------------------------------------------------
47
48 /*
49 WARNING: A kqueue retains itself while it is watching paths. If you want
50 to make sure a kqueue gets released, call removeAllPaths on it
51 before you release it.
52 */
53
54 @interface UKKQueue : NSObject <UKFileWatcher>
55 {
56 int queueFD; // The actual queue ID (Unix file descriptor).
57 NSMutableArray* watchedPaths; // List of NSStrings containing the paths we're watching. These match up with watchedFDs, as a dictionary that may have duplicate keys.
58 NSMutableArray* watchedFDs; // List of NSNumbers containing the file descriptors we're watching. These match up with watchedPaths, as a dictionary that may have duplicate keys.
59 id delegate; // Gets messages about changes instead of notification center, if specified.
60 id delegateProxy; // Proxy object to which we send messages so they reach delegate on the main thread.
61 BOOL alwaysNotify; // Send notifications even if we have a delegate? Defaults to NO for alloc/inited instances, YES for the singleton.
62 BOOL keepThreadRunning; // Termination criterion of our thread.
63 BOOL threadHasTerminated; // Feedback whether our thread has successfully quit.
64 }
65
66 +(id) sharedFileWatcher; // Returns a singleton, a shared kqueue object. Handy if you're subscribing to the notifications. Use this, or just create separate objects using alloc/init. Whatever floats your boat.
67
68 -(int) queueFD; // I know you unix geeks want this...
69
70 // High-level file watching:
71 -(void) addPath: (NSString*)path; // UKFileWatcher protocol, preferred.
72 -(void) addPath: (NSString*)path notifyingAbout: (u_int)fflags;
73 -(void) removePath: (NSString*)path; // UKFileWatcher protocol.
74 -(void) removeAllPaths; // UKFileWatcher protocol.
75
76 // For alloc/inited instances, you can specify a delegate instead of subscribing for notifications:
77 -(void) setDelegate: (id)newDelegate; // UKFileWatcher protocol.
78 -(id) delegate; // UKFileWatcher protocol.
79
80 -(void) setAlwaysNotify: (BOOL)n; // Send notifications even if we have a delegate.
81 -(BOOL) alwaysNotify;
82
83 @end
84
Something went wrong with that request. Please try again.