Re: problem of monitoring directory
- From: Aleksander Morgado <gtk-list aleksander es>
- To: shenoubang <oubang live cn>
- Cc: gtk-list gnome org
- Subject: Re: problem of monitoring directory
- Date: Fri, 8 Apr 2011 14:41:26 +0200
> I am very sorry to trouble you, but I can not handle a problem about my
> program for a long time, I hope someone can help me, thank you very much!
> The program is to monitor directories and report the events occoured in
> directory shuch as deleting files , creating files and so on. My program can
> monitor the directory and its child diectroy, and report the event that
> happened on a single file or directory, but it can only monitor the toppest
> directory and do not report the events when copy diredtory which contains
> many files.
> My code is in attachment, I would appreciate very much if someone help me
> to handle this problem, thank you very much!
>
GFileMonitor is not recursive (inotify in Linux is not recursive, and
the windows backend doesn't use the recursive monitoring operation).
Therefore, if you are monitoring a directory "A" and you copy inside
another directory "B" with lots of files inside, you will only get 1
event for "B" being created.
If you want to get events for all files within "B", you will need to
add a new GFileMonitor for the "B" directory as soon as you get the
CREATED event for it; and after that crawl the "B" directory
(g_file_enumerate_children() for example) so that you find files that
may have been already created in the meantime (between the directory
"B" being created and your program adding the monitor on it).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]