MYDirectoryWatcher.h
author Jens Alfke <jens@mooseyard.com>
Sat Mar 28 09:36:46 2009 -0700 (2009-03-28)
changeset 20 5a71993a1a70
child 31 2068331949ee
permissions -rw-r--r--
Added some new utilities, taken from Murky.
     1 //
     2 //  MYDirectoryWatcher.h
     3 //  Murky
     4 //
     5 //  Copyright 2008 Jens Alfke. All rights reserved.
     6 //
     7 
     8 #import <Cocoa/Cocoa.h>
     9 
    10 
    11 /* A wrapper for FSEvents, which notifies its delegate when filesystem changes occur. */
    12 @interface MYDirectoryWatcher : NSObject 
    13 {
    14     NSString *_path;
    15     id _target;
    16     SEL _action;
    17     UInt64 _lastEventID;
    18     BOOL _historyDone;
    19     CFTimeInterval _latency;
    20     FSEventStreamRef _stream;
    21 }
    22 
    23 - (id) initWithDirectory: (NSString*)path target: (id)target action: (SEL)action;
    24 
    25 @property (readonly,nonatomic) NSString* path;
    26 
    27 @property UInt64 lastEventID;
    28 @property CFTimeInterval latency;
    29 
    30 - (BOOL) start;
    31 - (void) pause;
    32 - (void) stop;
    33 - (void) stopTemporarily;               // stop, but re-start on next runloop cycle
    34 
    35 @end
    36 
    37 
    38 
    39 @interface MYDirectoryEvent : NSObject
    40 {
    41     MYDirectoryWatcher *watcher;
    42     NSString *path;
    43     UInt64 eventID;
    44     UInt32 flags;
    45 }
    46 
    47 @property (readonly, nonatomic) MYDirectoryWatcher *watcher;
    48 @property (readonly, nonatomic) NSString *path, *relativePath;
    49 @property (readonly, nonatomic) UInt64 eventID;
    50 @property (readonly, nonatomic) UInt32 flags;
    51 
    52 @property (readonly, nonatomic) BOOL mustScanSubdirectories;
    53 @property (readonly, nonatomic) BOOL eventsWereDropped;
    54 @property (readonly, nonatomic) BOOL isHistorical;   
    55 @property (readonly, nonatomic) BOOL rootChanged;
    56 
    57 @end