#include <FileChangeChecker.h>
Public Member Functions | |
FileChangeChecker (unsigned int maxSize=0) | |
Create a FileChangeChecker object. | |
bool | changed (const string &filename, unsigned int throttleRate=0) |
Checks whether, since the last call to changed() with this filename, the file's timestamp has changed or whether the file has been created or removed. | |
void | setMaxSize (unsigned int maxSize) |
Change the maximum size of the internal file list. | |
bool | knows (const string &filename) const |
Returns whether filename is in the internal file list. |
Example:
FileChangeChecker checker; checker.changed("foo.txt"); // false writeToFile("foo.txt"); checker.changed("foo.txt"); // true checker.changed("foo.txt"); // false
FileChangeChecker uses stat() to retrieve file information. It also supports throttling in order to limit the number of actual stat() calls. This can improve performance on systems where disk I/O is a problem.
Passenger::FileChangeChecker::FileChangeChecker | ( | unsigned int | maxSize = 0 |
) | [inline] |
Create a FileChangeChecker object.
maxSize | The maximum size of the internal file list. A size of 0 means unlimited. |
bool Passenger::FileChangeChecker::changed | ( | const string & | filename, | |
unsigned int | throttleRate = 0 | |||
) | [inline] |
Checks whether, since the last call to changed() with this filename, the file's timestamp has changed or whether the file has been created or removed.
If the stat() call fails for any other reason (e.g. the directory is not readable) then this method will return false.
If this method was called with this filename for the first time, or if information about this file has since been removed from the internal file list, then this method will return whether the file is stat()-able. That is, if the file doesn't exist then it will return false, but if the directory is not readable then it will also return false.
filename | The file to check. Note that two different filename strings are treated as two different files, so you should use absolute filenames if you change working directory often. | |
throttleRate | When set to a non-zero value, throttling will be enabled. stat() will be called at most once per throttleRate seconds. |
TimeRetrievalException | Something went wrong while retrieving the system time. | |
boost::thread_interrupted |
void Passenger::FileChangeChecker::setMaxSize | ( | unsigned int | maxSize | ) | [inline] |
Change the maximum size of the internal file list.
A size of 0 means unlimited.