File monitoring for all drive

Tim Golden mail at timgolden.me.uk
Sun May 27 11:07:43 EDT 2007


[rohit]
>>> i want to detect all file change operations(rename,delete,create....)
>>> on ALL THE DRIVES of the hard disk
>>> using the method ReadDirectoryChanges API , i.e program no. 3 in the
>>> webpagehttp://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_fo...
>>> .
>>> Please suggest some modification to the program so that i can detect
>>> changes to ALL the drives
>>> (to detect changes on c:\           set
>>> path_to_watch = "." to "c:\\"   but this works for only one drive

[Tim Golden]
>> Well, to answer the question specifically: since the
>> Windows filesstem has no concept of a "root" above
>> the drive letters, the simplest thing to do is to
>> kick off a thread or a subprocess or what-have-you
>> for each drive letter.

[rohit]
> actually i want to implement a deamon monitoring file changes on the
> system
> so u suggesting i should implement the program with multithreading to
> include all drives?

That's one possibility, but again I'd ask whether
this is really quite sane: you're asking the filesystem
to tell you about every change to every file on the
system which will naturally slow things down. It will
get even more complicated if you're actually storing
these "change logs" in a file somewhere, since that
will then fire the monitoring mechanism itself!

I suggest - again - that the NTFS change journal might
be better suited to what you're trying to do.

Try the threaded approach with the ReadDirectoryChanges
API *on a small area of disk* to see how well it scales.
Then you'll be better placed to decide if it will work
well across all the disks in the system.

TJG



More information about the Python-list mailing list