mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
EA-46653 (abort on FSEvent stream creation failure)
This commit is contained in:
@@ -68,24 +68,9 @@ static void callback(ConstFSEventStreamRef streamRef,
|
||||
}
|
||||
|
||||
static void * EventProcessingThread(void *data) {
|
||||
CFStringRef path = CFSTR("/");
|
||||
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&path, 1, NULL);
|
||||
void *callbackInfo = NULL;
|
||||
CFAbsoluteTime latency = 0.3; // Latency in seconds
|
||||
|
||||
FSEventStreamRef stream = FSEventStreamCreate(
|
||||
NULL,
|
||||
&callback,
|
||||
callbackInfo,
|
||||
pathsToWatch,
|
||||
kFSEventStreamEventIdSinceNow,
|
||||
latency,
|
||||
kFSEventStreamCreateFlagNoDefer
|
||||
);
|
||||
|
||||
FSEventStreamRef stream = (FSEventStreamRef) data;
|
||||
FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(stream);
|
||||
|
||||
CFRunLoopRun();
|
||||
return NULL;
|
||||
}
|
||||
@@ -169,13 +154,29 @@ int main(const int argc, const char* argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pthread_t threadId;
|
||||
if (pthread_create(&threadId, NULL, EventProcessingThread, NULL) != 0) {
|
||||
// Give up if cannot create a thread.
|
||||
CFStringRef path = CFSTR("/");
|
||||
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&path, 1, NULL);
|
||||
CFAbsoluteTime latency = 0.3; // Latency in seconds
|
||||
FSEventStreamRef stream = FSEventStreamCreate(
|
||||
NULL,
|
||||
&callback,
|
||||
NULL,
|
||||
pathsToWatch,
|
||||
kFSEventStreamEventIdSinceNow,
|
||||
latency,
|
||||
kFSEventStreamCreateFlagNoDefer
|
||||
);
|
||||
if (stream == NULL) {
|
||||
printf("GIVEUP\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
pthread_t threadId;
|
||||
if (pthread_create(&threadId, NULL, EventProcessingThread, stream) != 0) {
|
||||
printf("GIVEUP\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
fscanf(stdin, "%s", command);
|
||||
if (strcmp(command, "EXIT") == 0 || feof(stdin)) break;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
# Clang can be downloaded from from http://llvm.org/releases/download.html or found in XCode 4+
|
||||
# Clang can be downloaded from http://llvm.org/releases/download.html or found in XCode 4+
|
||||
clang -arch i386 -mmacosx-version-min=10.5 -framework CoreServices -o fsnotifier fsnotifier.c
|
||||
|
||||
Reference in New Issue
Block a user