private Pointer[] createFSEventStream() throws IOException { final Pointer root = cf.CFStringCreateWithCString(Pointer.NULL, "/", ENC_MAC_ROMAN); // NOI18N if (root == Pointer.NULL) { throw new IOException("Path creation failed."); // NOI18N } final Pointer arr = cf.CFArrayCreateMutable(Pointer.NULL, new NativeLong(1), Pointer.NULL); if (arr == Pointer.NULL) { throw new IOException("Path list creation failed."); // NOI18N } cf.CFArrayAppendValue(arr, root); final Pointer eventStream = cs.FSEventStreamCreate( Pointer.NULL, callback, Pointer.NULL, arr, kFSEventStreamEventIdSinceNow, LATENCY, kFSEventStreamCreateFlagNoDefer); if (eventStream == Pointer.NULL) { throw new IOException("Creation of FSEventStream failed."); // NOI18N } final Pointer loop = cf.CFRunLoopGetCurrent(); final Pointer kCFRunLoopDefaultMode = findDefaultMode(loop); if (kCFRunLoopDefaultMode == null) { throw new IOException("Caller has no defaul run loop mode."); // NOI18N } cs.FSEventStreamScheduleWithRunLoop(eventStream, loop, kCFRunLoopDefaultMode); if (LOG.isLoggable(DEBUG_LOG_LEVEL)) { LOG.log(DEBUG_LOG_LEVEL, getStreamDescription(eventStream)); } cs.FSEventStreamStart(eventStream); return new Pointer[] {eventStream, loop}; }