Sha256: 1c0e8219620518c3ea65941b4bdf1865dac0e41f14e27d2f5c8646f9f4a33757

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

#include <CoreServices/CoreServices.h>

void callback(ConstFSEventStreamRef streamRef,
  void *clientCallBackInfo,
  size_t numEvents,
  void *eventPaths,
  const FSEventStreamEventFlags eventFlags[],
  const FSEventStreamEventId eventIds[]
) {
  // Print modified dirs
  int i;
  char **paths = eventPaths;
  for (i = 0; i < numEvents; i++) {
    printf(paths[i]);
    printf(" ");
  }
  printf("\n");
  fflush(stdout);
}

int main (int argc, const char * argv[]) {
  // Create event stream
  CFStringRef pathToWatch = CFStringCreateWithCString(kCFAllocatorDefault, argv[1], kCFStringEncodingUTF8);
  CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&pathToWatch, 1, NULL);  
  void *callbackInfo = NULL;
  FSEventStreamRef stream;
  CFAbsoluteTime latency = 0.5;
  stream = FSEventStreamCreate(
    kCFAllocatorDefault,
    callback,
    callbackInfo,
    pathsToWatch,
    kFSEventStreamEventIdSinceNow,
    latency,
    kFSEventStreamCreateFlagNone
  );
  
  // Add stream to run loop
  FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
  FSEventStreamStart(stream);
  CFRunLoopRun();
  
  return 2;
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspactor-0.7.0.beta.2 ext/fsevent/fsevent_watch.c
rspactor-0.7.0.beta.1 ext/fsevent/fsevent_watch.c