0

On OSX, I'm using this technique to detect new files dragged, dropped, and created in a folder path (or subpath).

However, the Apple Documentation doesn't include any information on how to compute the value of FSEventStreamEventFlags.

So, through trial and error, I'm having to make an array like so:

const unsigned short TOTAL_EVENTS = 9;
unsigned int anEvents[TOTAL_EVENTS];
anEvents[0] = 125184; // download
anEvents[1] = 105728; // another way to download
anEvents[2] = 116992; // another way to download
anEvents[3] = 128256; // same folder paste
anEvents[4] = 108544; // new file created
anEvents[5] = 110848; // another way new file created
anEvents[6] = 67584; // file dragged in
anEvents[7] = 127232; // file inside folder that was dragged in
anEvents[8] = 128768; // file replace on paste

Please tell me that there has to be a better way? I mean, surely those numbers are the result of some bitwise ANDs on some base number, and then I can do this more scientifically instead of storing some constants?

Community
  • 1
  • 1
Volomike
  • 23,743
  • 21
  • 113
  • 209
  • 1
    The possible values are on that page you linked: [FSEventStreamEventFlags](https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/#//apple_ref/doc/constant_group/FSEventStreamEventFlags) – jtbandes Apr 17 '16 at 22:30
  • Wow, somehow I missed that! Okay, do you think I should delete this question? – Volomike Apr 17 '16 at 22:31
  • I think it's simple enough that it might not serve any purpose for other googlers. But, up to you! – jtbandes Apr 17 '16 at 22:32
  • Perhaps I should reword the question so that I can show how to use those flags to determine the bitwise operation? I mean, I'm stuck on figuring that out too. – Volomike Apr 17 '16 at 22:32
  • Sure. From what you've written so far, I'm not really clear on what you're trying to do. Are you trying to extract or combine flag values? – jtbandes Apr 17 '16 at 22:34
  • I'm working on a real-time connector to a third-party virus scanner API. So, I'm monitoring new file events (in the ways shown above) so that if indeed it's a downloaded file from the web (or the other events shown above), then I can send it to the scanner API for evaluation. – Volomike Apr 17 '16 at 22:36

0 Answers0