Page 1 of 1

Best way to observe a directory for changes?

Posted: Sun Dec 10, 2023 4:51 pm
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!

Re: Best way to observe a directory for changes?

Posted: Sun Dec 10, 2023 5:48 pm
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.

Re: Best way to observe a directory for changes?

Posted: Sun Dec 10, 2023 5:55 pm
by mrbungle
Thanks but these are windows-specific.

Re: Best way to observe a directory for changes?

Posted: Sat Dec 16, 2023 11:08 am
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.

Re: Best way to observe a directory for changes?

Posted: Tue Dec 19, 2023 8:46 pm
by mrbungle
Thank you

Re: Best way to observe a directory for changes?

Posted: Sat Dec 23, 2023 9:15 pm
by Piero

Re: Best way to observe a directory for changes?

Posted: Sun Dec 24, 2023 1:13 am
by mrbungle
Please stop with the Applescript references. This is a PureBasic forum.