public MacWatcher(string path) {
Path = path;
m_callback = DoCallback;
NSString[] s = new NSString[1];
s[0] = new NSString(path);
NSArray path_p = NSArray.FromNSObjects(s);
m_stream = FSEventStreamCreate( // note that the stream will always be valid
IntPtr.Zero, // allocator
m_callback, // callback
IntPtr.Zero, // context
path_p.Handle, // pathsToWatch
kFSEventStreamEventIdSinceNow, // sinceWhen
2, // latency (in seconds)
FSEventStreamCreateFlags.kFSEventStreamCreateFlagNone); // flags
FSEventStreamScheduleWithRunLoop(
m_stream, // streamRef
CFRunLoopGetMain(), // runLoop
kCFRunLoopDefaultMode); // runLoopMode
bool started = FSEventStreamStart(m_stream);
if (!started) {
GC.SuppressFinalize(this);
throw new InvalidOperationException ("Failed to start FSEvent stream for " + path);
}
}