-
-
Save ga2arch/23f63d5200b1a9a0c167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CoreServices/CoreServices.h> | |
#include <iostream> | |
void callback( | |
ConstFSEventStreamRef stream, | |
void *callbackInfo, | |
size_t numEvents, | |
void *evPaths, | |
const FSEventStreamEventFlags evFlags[], | |
const FSEventStreamEventId evIds[]) | |
{ | |
char const **paths = (char const**)evPaths; | |
for(int i = 0; i < numEvents; ++i) { | |
std::cout << (unsigned long long)evIds[i] << "\t" << | |
evFlags[i] << "\t" << | |
paths[i] << "\n" | |
; | |
} | |
} | |
int main(int argc, char **argv) | |
{ | |
CFStringRef arg = CFStringCreateWithCString( | |
kCFAllocatorDefault, | |
argv[1], | |
kCFStringEncodingUTF8); | |
CFArrayRef paths = CFArrayCreate(NULL, (const void**)&arg, 1, NULL); | |
void *callbackInfo = NULL; | |
FSEventStreamRef stream; | |
CFAbsoluteTime latency = 3.0; | |
stream = FSEventStreamCreate( | |
NULL, | |
&callback, | |
NULL, | |
paths, | |
kFSEventStreamEventIdSinceNow, | |
latency, | |
kFSEventStreamCreateFlagNone); | |
FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); | |
FSEventStreamStart(stream); | |
std::cout << "eventID\tFlag\tPath\n"; | |
CFRunLoopRun(); | |
FSEventStreamInvalidate(stream); | |
FSEventStreamRelease(stream); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment