Best way to observe a directory for changes?

Mac OSX specific forum
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

Best way to observe a directory for changes?

Post by mrbungle »

I am interesting in monitoring a specific directory to see if it's not empty. I know how to do this using a timer but polling that way isn't very elegant. Does anyone know how to set up an observer I can treat as an event to handle this logic more efficiently?

Thank you in advance!
normeus
Enthusiast
Enthusiast
Posts: 472
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Best way to observe a directory for changes?

Post by normeus »

A while back there was some code to keep an eye on directory changes. it might still work:

https://www.purebasic.fr/english/viewto ... 82#p542582

It should be easy to update to latest PB

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

Re: Best way to observe a directory for changes?

Post by mrbungle »

Thanks but these are windows-specific.
User avatar
deseven
Enthusiast
Enthusiast
Posts: 367
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Best way to observe a directory for changes?

Post by deseven »

There's a native API that solves this, called FSEvents. I'm not sure exactly how to use it from PB since you need to process incoming events, but maybe this will point you in the right direction or someone else can figure it out.
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

Re: Best way to observe a directory for changes?

Post by mrbungle »

Thank you
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

Re: Best way to observe a directory for changes?

Post by mrbungle »

Please stop with the Applescript references. This is a PureBasic forum.
Post Reply