[python-win32] ReadDirectoryChangesW working

Jos Yule jos@trapeze.com
Tue, 21 Jan 2003 14:21:01 -0500


First of all, thank you, thank you, thank you.
Very very cool. 

Now i just have to figure out how it works. It seems to block till there is a change, then it 'returns' the change info. Going to have to play with it a bit to get it all figured out.

Again, thanks for this!

jos

ps. Needed to add the following to the win32con.py file:

FILE_LIST_DIRECTORY = 0x0001

<code>
import os
import sys
import time

import win32file
import win32con

try: path_to_watch = sys.argv[1] or "."
except: path_to_watch = "."
path_to_watch = os.path.abspath (path_to_watch)

print "Watching %s at %s" % (path_to_watch, time.asctime ())

hDir = win32file.CreateFile(
    path_to_watch,
    win32con.FILE_LIST_DIRECTORY,
    win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,
    None,
    win32con.OPEN_EXISTING,
    win32con.FILE_FLAG_BACKUP_SEMANTICS,
    None
)
   
print win32file.ReadDirectoryChangesW(
    hDir,
    1024,
    0,
    win32con.FILE_NOTIFY_CHANGE_LAST_WRITE,
    None,
    None
)
</code>

-- 


Jos Yule
EWACT (employee without a cool title)

Trapeze
2 Berkeley St. Suite 305
Toronto, On, CANADA
M5A 4J5

t: 416 601 1999 x227
f: 416 601 1997
e: mailto:jos@trapeze.com
w: http://www.trapeze.com