WebFreak001 / FSWatch

A cross-platform folder & file watching library using win32, inotify or std.file
33 stars 8 forks source link

Directory watching on Windows doesn't work #15

Closed helikopterodaktyl closed 5 years ago

helikopterodaktyl commented 6 years ago

Code like this:

watcher = FileWatch("C:/test/", true); while (1) { foreach (event; watcher.getEvents()) { writeln(event.path); } }

when ran and creating/deleting/modifying files in C:\test\ directory, no paths get written to stdout

WebFreak001 commented 6 years ago

works fine here under windows 10 VM

helikopterodaktyl commented 6 years ago

Interesting. Doesn't work with my Windows 10. I am using the 0.3.0 version of the library. Watching a file works, just the directory that doesn't.

WebFreak001 commented 6 years ago

having the folder there before starting and after starting doesn't make a difference. Have you tried exactly running your example code and not in the application?

helikopterodaktyl commented 6 years ago

Well... I restarted everything, IDE and all, rebuilt my app from scratch and it's working now. I have no idea why it didn't work before...

helikopterodaktyl commented 6 years ago

Ahhh. I see the issue. I don't know what is causing it, perhaps some threading related issue? If the FileWatch variable is a global, it doesn't work.

doesn't work:

FileWatch watcher;
void main() { watcher = FileWatch(... }

works: void main() { FileWatch watcher = FileWatch(... }

Is this expected? I don't see why would one work, but not another.

WebFreak001 commented 6 years ago

hm there is some destruction code, does it work if you comment out line 106 (CloseHandle(pathHandle);) for testing purposes?

helikopterodaktyl commented 6 years ago
void main() { FileWatch watcher; watcher = FileWatch(... }

declaring it like this also doesn't work. Works only if watcher is assigned during the declaration.

let me check

WebFreak001 commented 6 years ago

as workaround try FileWatch* watcher; watcher = new FileWatch(...);

helikopterodaktyl commented 6 years ago

Yes, the pointer works. Is this some obvious D thing that I am missing? I don't see what difference would it make.

WebFreak001 commented 6 years ago

have you tried commenting the code I told you to to see if it works without pointer then?

helikopterodaktyl commented 6 years ago

Yes, doesn't seem to have an effect :(

WebFreak001 commented 6 years ago

uh you have used the exact code you have initially posted + a declaration right? I don't really want to boot up my VM again...

If commenting that line doesn't change it I don't really know what could be causing it

helikopterodaktyl commented 6 years ago

Yes, exact code. Oh well, the pointer works for me, so I consider it non-issue.

WebFreak001 commented 5 years ago

with v0.5.0 that assignment issue should be fixed too