Closed bausshf closed 6 years ago
oh yeah that will be the case, you could just make them pointers (FileWatch*[] watchers; watchers ~= new FileWatch(path, true);
) though.
OR if you just foreach over it like you do foreach by ref: foreach (ref watcher; watchers)
Yeah, using pointers work, but meh.
I'll close this ig.
This is not working.
auto sw = FileWatch("shader", true);
FileWatch[] watchers;
watchers~= sw;
//loop
//don´t show anything
foreach (event; watchers[0].getEvents())
event.print;
//show properly
foreach (event; sw.getEvents())
event.print;
looking at the code now, but not seeing anything wrong, yet.
Ok got it.
In my case (Windows), once you create the FileWatch, you already queue that into windows ReadDirectoryChangesW
but the change buffer is a new one on the copy stored on the array.
So if you don´t call getEvents()
on FileWatch
ctor or you set the queue to false again(watchers[0].queue = false;
), it works properly.
(but queue is private btw :P)
Is it possible to create multiple watchers and store them in an array and then loop that array in a while loop to watch for events?
I can't seem to get that working and I suspect it doesn't work, because FileWatch is a struct?
Perhaps if FileWatch was a class it would work?
Basically what I'm doing now is this: (Minimal example)
I create an array like:
Then I load the watchers from a config file with the paths:
And then I do this:
Maybe I'm using it wrong?
Also I'm on Windows. Could it be a Windows issue?