Skip to content

gcstang/spideroak_windows_dir_watcher

 
 

Repository files navigation

spideroak_windows_dir_watcher

This program is what we at SpiderOak call a 'dir watcher'. It uses The Win32 API to get low level notification of changes in the filesystem. We have other dir watchers for OS X (spideroak_osx_fsevents) and Linux (spideroak_inotify_dir_watcher).

The goals of the dir watchers are:
* To recognize filesystem events in an efficient way
* To have a small footprint: using as little memory and processor time as possible
* To be robust 
 
So these dir watchers are very simple programs, keeping the complication in the Python program which uses them. 

This program is launched by the SpiderOak back end program (the 'spider'). It reads a configuration file listing directories to by watched. And it reads an 'exclude' file (which may be empty) listing directories to be ignored. When it detects an event (or events), it writes a simple notification file to a specified directory.

To build the executable you can use build.cmd.

We have included the python program launch_watcher.py for your convenience in testing. It launches the watcher the same way our spider program does.

Here's a sample test run:

The config file is config.txt. It contains:

e:\test_data
e:\test_dir
e:\unicode_test
e:\notification

The exclude file is exclude.txt. It contains:

e:\notification

The notification directory is e:\notification

The test is run like this:

python launch_watcher.py \
    spideroak_windows_dir_watcher.exe \ 
    e:\config.txt \
    e:\exclude.txt \
    e:\notification

Note the use of full path names, this is the way the spider runs it.

When I remove a file from e:\test_dir, we see some events:

dir e:\notification/
00000001.txt

and in 00000001.txt 
e:\test_dir

$ cat ~/notification/00000002.txt 
/Users/dougfort/Desktop/

Note that the notification is simply the directory where the event occurred. The Win32 API (and the .NET CLR) will provide a lot more information than that. Our goal is to keep the dir watcher as simple as possible. Of course, this is open source, if you want something more complicated go for it. (Please see our LICENSE).

You need to distribute some Visual C++ runtime DLLs wiht this program. 

This is part of SpiderOak
http://SpiderOak.com

contact us at code@spideroak.com

About

lightweight filesystem change notification utility for Windows

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 73.7%
  • C 20.6%
  • Batchfile 5.7%