After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 517419 - gio win32 directory monitor
gio win32 directory monitor
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
2.15.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-19 11:22 UTC by Vlad Grecescu
Modified: 2008-03-12 19:12 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
win32 directory monitor (29.04 KB, patch)
2008-02-19 11:22 UTC, Vlad Grecescu
needs-work Details | Review
now using g_utf16_to_utf8 () (29.23 KB, patch)
2008-02-19 16:50 UTC, Vlad Grecescu
needs-work Details | Review
implemented without gsource/events (11.59 KB, patch)
2008-02-26 15:11 UTC, Vlad Grecescu
none Details | Review
implemented without gsource/events (+finalize mess cleanup) (11.88 KB, patch)
2008-02-27 11:53 UTC, Vlad Grecescu
none Details | Review

Description Vlad Grecescu 2008-02-19 11:22:14 UTC
Attached is a patch that implements a gio directory monitor.
Notes:
 - it is based on the native ReadDirectoryChanges Win32 call. It is only a directory watcher, I saw a polling file watcher exists already 
 - it registers itself as a GSource - it wouldn't have been necessary if the glib main loop would have used MsgWaitForMultipleObjectsEx 
 - it's a GModule, like the fam monitor. Thinking that inotify is compiled-in on linux, I think the same can be said for windows about ReadDirectoryWatcher 
 - it may have bugs / may need code cleanup? it's here to be tested.. 

Regards,
Comment 1 Vlad Grecescu 2008-02-19 11:22:58 UTC
Created attachment 105572 [details] [review]
win32 directory monitor

Initial implementation as GModule
Comment 2 Tor Lillqvist 2008-02-19 11:59:02 UTC
> it registers itself as a GSource - it wouldn't have been necessary 
> if the glib main loop would have used MsgWaitForMultipleObjectsEx

If you can come up with a simple enhancement to the glib main loop implementation on Win32 that preserves backward compatibility, while making your directory monitor simpler, I wouldn't object at all.

I haven't yet looked in detail at the patch, but I noticed it uses WideCharToMultiByte() to convert a wide-char filename to system codepage, then passes that to g_file_new_for_path(). In general all file names passed to and returned from GLib APIs are in UTF-8 on Windows, so you should use g_utf16_to_utf8() instead. (If g_file_new_for_path() in fact *does* currently expect a pathname in system codepage, that is then a bug.)
Comment 3 Vlad Grecescu 2008-02-19 16:50:54 UTC
Created attachment 105588 [details] [review]
now using g_utf16_to_utf8 ()

Sorry, I left that unintentionally - I use g_utf15_to_utf8 () now (and I fixed a leak too) in the next patch.

For the main loop I wrote on #517484. On my machine it does not have side effects but YMMV.
Comment 4 Tor Lillqvist 2008-02-24 02:04:28 UTC
> it registers itself as a GSource - it wouldn't have been necessary if 
> the glib main loop would have used MsgWaitForMultipleObjectsEx 

That change has now been committed, so could you simplify the code correspondingly? (Or did I misunderstand something...?)

Please make it into a static archive that is always linked into libgio, like libinotify on Linux.

Also, the patch contains two copies of each diff to gio/win32...
Comment 5 Vlad Grecescu 2008-02-26 15:11:49 UTC
Created attachment 105987 [details] [review]
implemented without gsource/events

Ok, here's the source code with the implementation without CreateEvent () => g_source_attach ()

Also, it's linked directly, just like the inotify monitor.

One quirk, though: it still needs a gmain.c modification I overlooked (see bug #517484)

If it's not possible to make it, I can still submit the old version directly linked.
Comment 6 Vlad Grecescu 2008-02-27 11:53:17 UTC
Created attachment 106059 [details] [review]
implemented without gsource/events (+finalize mess cleanup)

Cleaned up some finalize () mess from the previous patch
Comment 7 Tor Lillqvist 2008-03-12 19:12:04 UTC
Patch committed to trunk, thanks! (Now I only need to find some suitable small test application to test the new, and gio functionality in general, on Windows...) Feel free to reopen this bug if/when you have further changes. Once we are sure this stuff works fine it probably can be committed to the stable glib-2-16 branch, too, as it doesn't introduce any new API as such.