Prev: ANNOUNCE: TkDND 2.2
Next: calling back TCL from C
From: Fredrik Karlsson on 4 Aug 2010 05:31 Dear group, I need to monitor something in the range of 1000 to 10,000 files in a directory for updates in the most efficient manner possible. What I am doing now is to store file modification information and then going through them one by one at timed intervals to se if the mdate has changed. Now, is this the only way, or are there some clever file event trickery I can use to make system do the work for me? I am talking about whole-file updates of files, and on platforms including Linux, Mac OS X and Windows. I tried fileevent readable but that seems to fire continously whatever I do. Thankful for any suggestion. /Fredrik
From: Alexandre Ferrieux on 4 Aug 2010 06:00 On Aug 4, 11:31 am, Fredrik Karlsson <dargo...(a)gmail.com> wrote: > Dear group, > > I need to monitor something in the range of 1000 to 10,000 files in a > directory for updates in the most efficient manner possible. What I am > doing now is to store file modification information and then going > through them one by one at timed intervals to se if the mdate has > changed. Now, is this the only way, or are there some clever file > event trickery I can use to make system do the work for me? > > I am talking about whole-file updates of files, and on platforms > including Linux, Mac OS X and Windows. > I tried fileevent readable but that seems to fire continously whatever > I do. > > Thankful for any suggestion. > > /Fredrik Fileevents monitor communication channels, not storage. To monitor the filesystem efficiently, you need OS-specific support as explained in http://groups.google.com/group/comp.lang.tcl/tree/browse_frm/thread/a7c0649cee5a103d/104652584a4bca17?rnum=1&q=inotify&_done=%2Fgroup%2Fcomp.lang.tcl%2Fbrowse_frm%2Fthread%2Fa7c0649cee5a103d%2F9790a6c005e12870%3Flnk%3Dgst%26q%3Dinotify%26#doc_9790a6c005e12870 That said, you mentioned whole-file updates; beware that without extra synchronization efforts, the low-level notification may wake you up in the middle of an update. Atomic filesystem ops like rename() can help in this area. -Alex
From: Rob on 4 Aug 2010 06:36 Fredrik Karlsson wrote: > Dear group, > > I need to monitor something in the range of 1000 to 10,000 files in a > directory for updates in the most efficient manner possible. What I am > doing now is to store file modification information and then going > through them one by one at timed intervals to se if the mdate has > changed. Now, is this the only way, or are there some clever file > event trickery I can use to make system do the work for me? > > I am talking about whole-file updates of files, and on platforms > including Linux, Mac OS X and Windows. > I tried fileevent readable but that seems to fire continously whatever > I do. > > Thankful for any suggestion. Fredrik Not necessarily tcl-related, but you could use inotify under Linux and the equivalent API call under Windows. I'm sure that MacOS X has something similar. It may even be possible to monitor the relevant operating system events using tcl :) Rob.
From: Rob on 4 Aug 2010 07:01 Rob wrote: > Fredrik Karlsson wrote: > >> Dear group, >> >> I need to monitor something in the range of 1000 to 10,000 files in a >> directory for updates in the most efficient manner possible. What I am >> doing now is to store file modification information and then going >> through them one by one at timed intervals to se if the mdate has >> changed. Now, is this the only way, or are there some clever file >> event trickery I can use to make system do the work for me? >> >> I am talking about whole-file updates of files, and on platforms >> including Linux, Mac OS X and Windows. >> I tried fileevent readable but that seems to fire continously whatever >> I do. >> >> Thankful for any suggestion. > > Fredrik > > Not necessarily tcl-related, but you could use inotify under Linux and the > equivalent API call under Windows. I'm sure that MacOS X has something > similar. > > It may even be possible to monitor the relevant operating system events > using tcl :) After I made my initial very vague comment, I checked on the net about this area with respect to tcl and got the following: http://wiki.tcl.tk/3643 http://sourceforge.net/projects/tcl-inotify/ I didn't see any mention to MacOS X, but there I'd imagine there would be an equivalent O/S function available. I hope this is of some use for you. I have used software which monitors directories in the way you want, so I'm pretty sure that what you want is eminently do-able. Rob.
From: Harald Oehlmann on 4 Aug 2010 09:23
On 4 Aug., 11:31, Fredrik Karlsson <dargo...(a)gmail.com> wrote: > Dear group, > > I need to monitor something in the range of 1000 to 10,000 files in a > I am talking about whole-file updates of files, and on platforms > including Linux, Mac OS X and Windows. On windows, the brilliant twapi offers this with the command "begin_filesystem_monitor" http://twapi.magicsplat.com/disk.html |