Posts Tagged ‘SimpleFileWatcher’

SimpleFileWatcher: New version

Monday, September 14th, 2009

Just released a new version of SimpleFileWatcher. Not a lot of new content, but a pretty serious bug was fixed for Win32 and some better error handling. I create some more maintainable build scripts using premake. Also, I moved the OgreDemo off to its own directory to help contain all the files.

Download: SimpleFileWatcher 2009.09.14

FileWatcher becomes SimpleFileWatcher

Thursday, May 14th, 2009

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

FileWatcher now supports OSX/BSD via kqueue

Wednesday, March 4th, 2009

Now not only does FileWatcher support Win32 and Linux, but it supports OSX/BSD/anything else using kqueue. This should cover 90% of the cases where this functionality is needed and I'm planning on a fallback mode that will just use directory scans and file timestamps to determine changes.

Get the new version here:
FileWatcher 2009.03.04

FileWatcher library watches files while you play

Tuesday, February 17th, 2009

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