Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Read Me About Watcher.txt
Read Me About Watcher |
===================== |
1.4 |
Watcher is a simple demonstration of the FSEvents API. It monitors a directory hierarchy and keeps track of the total size of the data contained in it. When a directory inside it changes, it recalculates the size of that directory and updates the total size. |
As the FSEvents API is being introduced in Leopard, Watcher requires the Leopard Beta or later. |
Packing List |
------------ |
The sample contains the following items: |
o Read Me About Watcher.txt -- This file. |
o Watcher.xcodeproj -- An Xcode project for the sample. |
o Watcher.c -- Source code for the program. |
o build -- A directory containing a pre-built version of the program. |
Using the Sample |
---------------- |
To use this sample, start by creating a directory to watch (the following assumes you downloaded the sample to the desktop): |
$ cd Desktop/Watcher |
$ mkdir ToWatch |
Then run Watcher against that directory: |
$ build/Debug/Watcher ToWatch |
Initial total size is: 0 for path: /Users/quinn/Desktop/Watcher/ToWatch |
Then, in another Terminal window, copy some files into that directory. |
$ cp /mach_kernel ~/Desktop/Watcher/ToWatch/ |
Watcher will notice the new files and print a line showing the new total size: |
New total size: 9052188 (change made to: /Users/quinn/Desktop/Watcher/ToWatch) for path: /Users/quinn/Desktop/Watcher/ToWatch |
Watcher supports a number of other command line arguments. Run Watcher with no arguments to get a short description of them: |
$ build/Debug/Watcher |
Usage: build/Debug/Watcher <flags> <path> |
[...] |
Building the Sample |
------------------- |
The sample was built using Xcode from the Leopard Beta. You should be able to just open the project, and choose Build from the Build menu. |
Credits and Version History |
--------------------------- |
If you find any problems with this sample, mail <dts@apple.com> and I'll try to fix them up. |
1.4 (June 2007) Simplified the code by eliminating custom logging routines and unnecessary command line arguments. |
1.3 (June 2007) Improved event reporting and recursive directory watching. |
1.2 (Aug 2006) Latest updates to fix directory size calculation. |
1.1 (Aug 2006) Simplify things by only dealing with a single path. |
1.0 (Aug 2006) First shipping version. |
Share and Enjoy |
Apple Developer Technical Support |
Networking, Communications, Hardware |
Copyright © 2006 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2006-08-04