FileWatcher becomes SimpleFileWatcher

I finally got around to doing a little more work on FileWatcher and decided it needed an official home.  Then comes the compoundingly obvious problem of giving a product such a generic title.  Sure FileWatcher fits the purpose, but there are about 1.5 billion other projects/products with the same title.  So the new title is SimpleFileWatcher, and with that comes two new features for users of SimpleFileWatcher.  SFW is now under the MIT License, so no worries about using the code in commercial products.  And secondly, it is hosted on Google Code.

SimpleFileWatcher

And the new release:

SimpleFileWatcher v.2009.05.14

Read More

FileWatcher library watches files while you play

Spurred by an article a while back in Game Developer Magazine, I decided to write a little cross platform library for detecting changes in files. The library works in both Windows and Linux (tested in ubuntu 8.10, but should work in anything with inotify) with support soon coming to OSX. The library is great for automatically updating game resources during development. Most real game engines have this these days, and now everyone else can too!

The library comes with two samples. OgreDemo.cpp shows a simple example of reloading textures on the fly using the Ogre3D engine. SimpleDemo.cpp just watches a directory and outputs the file names when a file changes.

Some example code:

// Create the object
FW::FileWatcher* fileWatcher = new FW::FileWatcher();
 
// add a directory watch
FW::WatchID watchid = fileWatcher->addWatch("..\\media", new UpdateListener());
 
...
 
// somewhere in your update loop call update
fileWatcher->update();
 
// where UpdateListener is defined as such
class UpdateListener : public FW::FileWatchListener
{
public:
    UpdateListener() {}
    void handleFileAction(FW::WatchID watchid, const String& dir,
                                    const String& filename,
                                    FW::FileWatcher::Action action)
    {
        std::cout << "File (" << dir + \\ + filename << ") has event "
                        << action << std::endl;
    }
};

Download version 2009.02.17

Read More