septag / dmon

Single header C99 portable library for monitoring filesystem changes. (Windows/Linux/MacOS)
BSD 2-Clause "Simplified" License
235 stars 19 forks source link

Couple fixes for the windows backend #34

Open fgenesis opened 3 months ago

fgenesis commented 3 months ago

First time dmon user, and it immediately blew up! (When trying to set a watch to a directory that didn't exist. win10.) So here's a bunch of fixes to make it work more reliably.

Copied from the commit:

I've been thinking to remove the weird "freelist" construct too, if you're ok with that.

Because we can just loop over the (compile-time-bounded) array of active watches and pick the first index that's NULL. Since adding and removing watches is nothing done on a per-frame basis a couple loop iterations don't matter. I'd prefer the gained simplicity.

_dmon.quit should be at least volatile (done now), but an atomic would be even better. Comments?

Lasty, do you mind if i get rid of the #include for the windows backend? Because I like backwards compatbility with older compilers and this is the single most annoying header to break MSVC <= 2012-ish compatibility.

I'll add some extra commits to the PR when i get the go-ahead from you.