1

i require a callback within my code (in C++) which fires every time a particular file is modified (after a save), i am using a Mac however not Xcode, i am building my code using g++, documentation for this seems to be very limited. Does anyone have any example code which performs this functionality? Or can point me in the right direction as to where to look?

godzilla
  • 3,005
  • 7
  • 44
  • 60
  • Take a look at boost filesystem library. here you've got example:http://www.highscore.de/boost/file_monitor.zip – LukeCodeBaker Sep 27 '13 at 20:29
  • not the same question, i need a callback within the code i am writing , not an independent program which monitors a file – godzilla Sep 27 '13 at 20:31

1 Answers1

0

On Linux you would use ionotify, but OSX has FSEvents. It seems it will only notify you about changes to directories, it's up to you to then see if the event was about your file or not. There's a C API. This question has some examples.

Community
  • 1
  • 1
Adam
  • 16,808
  • 7
  • 52
  • 98
  • i am surprised about the lack of examples around, seeming it should be a solved problem – godzilla Sep 27 '13 at 20:51
  • It's not a common operation. But there are examples around. Even Apple has some: https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html#//apple_ref/doc/uid/TP40005289-CH4-SW4 – Adam Sep 27 '13 at 22:50