How to subscribe to folder change

Hello, I am new to Odin. As a first project I made a small watcher utility to check my screen recording folder for changes.
The problem I am facing is that I am doing polling (every n sec) and check mtime on destination folder before checking for new files. Is there a way to subscribe to folder change event and avoid polling? The main target OS is MacOS but thinking on targeting Linux as well.

Hi and welcome to the forum! I can at least point you in a direction. The API on Linux is inotify. If you search for it in the odin packages, you will find bindings for it. Based on that, you might also find out what to do on MacOS

1 Like

I’ve come across the idea that filesystem notification APIs are not actually resilient sadly. Unfortunately I can’t really give you any details about that.
I can however say that in my fartings about with such things, I have found duplicate messages to arrive.
It may be more robust to routinely os.stat all files you want to check for changes, and if you get a message that one changed via the FS notifications, as an extra, then cool.
Off the top of my head, perhaps get notifications on directories only and then stat the files to get further information?