How to tell when a file is opened

Tim Golden mail at timgolden.me.uk
Sun Apr 8 03:07:52 EDT 2007


momobear wrote:
>> Will look into NTFS change journals when I get some spare time.
> How can we get NTFS change journals? Is there any API for this purpose
> or we could implement our own?
> there're an api in windows help us montior file changes.
> win32file.ReadDirectoryChangesW

Don't know what the API is but whatever it ends up being,
there's always ctypes. This article:

   http://www.codeproject.com/useritems/Eyes_on_NTFS.asp

points to DeviceIOControl and CreateFile, both in the
win32file module.

The problem with win32file.ReadDirectoryChangesW, which the
OP probably saw when he looked at my site (though he doesn't
actually say so) is that you're trying to monitor *an entire
hard disk*, maybe more. And you'll almost certainly run into
buffer shortfalls or even performance issues. But I don't
really have access to a big enough or used enough disk to
carry out a meaningful test.

TJG




More information about the Python-list mailing list