DESCRIPTIONWatchFile is useful for firing downstream modules when a file is modified.
WatchFile watches for modifications to a file and fires it's Filename ports when the file changes. Firing of the module occurs when the user types in a new file name or when the watched file changes it's modification time.
If a Trigger Filename is specified, Watchfile fires only when the trigger file has been modified, not when the main file specified by Filename has been modified. This is useful because UNIX provides no mechanism for watching when a file has been closed by another process. Because of this, we have no idea of when another process has completed its modifications of the watched file. In this situation, each write to the watched file could cause register a new modification time for the watched file thus firing Watchfile, even though the writes the file we are watching have not been completed. To provide a synchronization mechanism, a second Trigger Filename can be specified. The process writing the file Filename, should modify the trigger file when it has completed writing to file Filename. The following shell script is an example of writing a datafile and modifying the trigger file upon completion:
echo "Write once" > data echo "Write twice" >> data
To remove a trigger file, the Trigger Filename must be completely deleted.
In the situation that the file specified as the trigger file, whether by default or explicitly, does not exist, the module will not fire any downstream modules.
To use Watchfile in a map, wire the Filename parameter output into the Filename parameter input of a module which reads a datafile such as a DataScribe reader module, ReadImg, or ReadLat.
Port: Trigger Filename
SEE ALSOtouch(1) stat(2)
[ Documentation Home ] © The Numerical Algorithms Group Ltd, Oxford UK. 1996