WANTED: logging of all file operations on Windows

Paul McGuire ptmcg at austin.rr._bogus_.com
Sun Jul 9 14:05:55 EDT 2006


"faulkner" <faulkner612 at comcast.net> wrote in message
news:1152460915.363598.268980 at b28g2000cwb.googlegroups.com...
> you want a directory watching daemon. it isn't hard at all to build
> from scratch.
> first, determine which directories should be watched.
> then, os.walk each directory, building a mapping from filename to mtime
> [modified time; os.path.getmtime].
> next is your main event loop. this while loop consists of os.walk-ing
> each directory again, comparing the current mtime to the corresponding
> entry in the mapping. if they differ, or if a filename isn't in the
> mapping, something happened, at which point you can logick out whether
> a file was moved, deleted, changed, or created.
>
> so many folks have looked for this that i'll just write a generic one
> and put it in the cheeseshop. look for "dirmon" in about a week.
>
>
Ahem... (sorry for premature usenet-post-ication...)

While I am a big fan of "brute force", there are OS services (at least on
Windows) for doing just this function, with asynchronous callbacks when
files are created, deleted, etc.

Here is a link that does a much better comparison of several options than I
could (including your brute force version):
http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html

Good luck!
-- Paul





More information about the Python-list mailing list