title: OSX FSEventStreamEventFlags not working correctly
body: <p>I am watching a directory for file system events. Everything seems to work fine with one exception. When I create a file the first time, it spits out that it was created. Then I can remove it and it says it was removed. When I go to create the same file again, I get both a created and removed flag at the same time. I obviously am misunderstanding how the flags are being set when the callback is being called. What is happening here?</p>
  
  <pre><code>//
  //  main.c
  //  GoFSEvents
  //
  //  Created by Kyle Cook on 8/22/13.
  //  Copyright (c) 2013 Kyle Cook. All rights reserved.
  //
  
  #include &lt;CoreServices/CoreServices.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void eventCallback(FSEventStreamRef stream, void* callbackInfo, size_t numEvents, void* paths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
      char **pathsList = paths;
  
      for(int i = 0; i&lt;numEvents; i++) {
          uint32 flag = eventFlags[i];
  
          uint32 created = kFSEventStreamEventFlagItemCreated;
          uint32 removed = kFSEventStreamEventFlagItemRemoved;
  
          if(flag &amp; removed) {
              printf("Item Removed: %s\n", pathsList[i]);
          }
          else if(flag &amp; created) {
              printf("Item Created: %s\n", pathsList[i]);
          }
      }
  }
  
  int main(int argc, const char * argv[])
  {
      CFStringRef mypath = CFSTR("/path/to/dir");
      CFArrayRef paths = CFArrayCreate(NULL, (const void **)&amp;mypath, 1, NULL);
  
      CFRunLoopRef loop = CFRunLoopGetMain();
      FSEventStreamRef stream = FSEventStreamCreate(NULL, (FSEventStreamCallback)eventCallback, NULL, paths, kFSEventStreamEventIdSinceNow, 1.0, kFSEventStreamCreateFlagFileEvents | kFSEventStreamCreateFlagNoDefer);
      FSEventStreamScheduleWithRunLoop(stream, loop, kCFRunLoopDefaultMode);
      FSEventStreamStart(stream);
  
      CFRunLoopRun();
  
      FSEventStreamStop(stream);
      FSEventStreamInvalidate(stream);
      FSEventStreamRelease(stream);
  
      return 0;
  }
  </code></pre>