共有 0 个贴子
没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > simplefilewatcher |
simplefilewatcher
|
0 | 0 | 16 |
贡献者 | 讨论 | 代码提交 |
SimpleFileWatcher is a C++ wrapper for OS file monitoring systems. Currently it uses Win32 ReadDirectoryChangesW for monitoring changes in Windows, and inotify in linux. OSX is supported via kqueue and directory scans.
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::Action action)
{
switch(action)
{
case FW::Actions::Add:
std::cout << "File (" << dir + "\\" + filename << ") Added! " << std::endl;
break;
case FW::Actions::Delete:
std::cout << "File (" << dir + "\\" + filename << ") Deleted! " << std::endl;
break;
case FW::Actions::Modified:
std::cout << "File (" << dir + "\\" + filename << ") Modified! " << std::endl;
break;
default:
std::cout << "Should never happen!" << std::endl;
}
};A sample integrating SFW with Ogre3D is packaged with the source.