Source

NPAPI-chrome-file-api / Win / FileWatcherWin.cpp

#include "FileWatcherWin.h"

FileWatcher* FileWatcher::get()
{
    static FileWatcherWin inst;
    return &inst;
}

void FileWatcherWin::WatchFile(std::string key, std::string path, FB::JSObjectPtr callback)
{
	FileWatcherTaskWin* task = watchers[key];
	if (!task)
	{
		boost::filesystem::path p(path);
		if (is_directory(p))
		{
			task = new FileWatcherTaskWin(path,callback);
			task->StartWatching();
			watchers[key] = task;
		}
	}

}
void FileWatcherWin::StopWatching(std::string key)
{
	FileWatcherTaskWin* task = watchers[key];
	if (task)
	{
		task->StopWatching();
		watchers.erase(key);
		delete task;
	}
}