interface/file_watch: Rename MultiFileWatch to FileWatch

This commit is contained in:
Perttu Ahola 2014-10-04 08:31:29 +03:00
parent d988d518d8
commit e050dec31d
5 changed files with 23 additions and 23 deletions

View File

@ -33,12 +33,12 @@ struct Module: public interface::Module, public client_file::Interface
{
interface::Server *m_server;
sm_<ss_, sp_<FileInfo>> m_files;
sp_<interface::MultiFileWatch> m_watch;
sp_<interface::FileWatch> m_watch;
Module(interface::Server *server):
interface::Module("client_file"),
m_server(server),
m_watch(interface::createMultiFileWatch())
m_watch(interface::createFileWatch())
{
log_v(MODULE, "client_file construct");
}

View File

@ -13,7 +13,7 @@
namespace interface {
struct CMultiFileWatch: MultiFileWatch
struct CFileWatch: FileWatch
{
struct WatchThing {
ss_ path;
@ -26,16 +26,16 @@ struct CMultiFileWatch: MultiFileWatch
int m_fd = -1;
sm_<int, sp_<WatchThing>> m_watch;
CMultiFileWatch()
CFileWatch()
{
m_fd = inotify_init1(IN_NONBLOCK);
log_d(MODULE, "CMultiFileWatch(): m_fd=%i", m_fd);
log_d(MODULE, "CFileWatch(): m_fd=%i", m_fd);
if(m_fd == -1){
throw Exception(ss_()+"inotify_init() failed: "+strerror(errno));
}
}
~CMultiFileWatch()
~CFileWatch()
{
close(m_fd);
}
@ -79,12 +79,12 @@ struct CMultiFileWatch: MultiFileWatch
if(r == -1){
if(errno == EAGAIN)
break;
log_w(MODULE, "CMultiFileWatch::report_fd(): read() failed "
log_w(MODULE, "CFileWatch::report_fd(): read() failed "
"on fd=%i: %s", fd, strerror(errno));
break;
}
if(r < (int)INOTIFY_STRUCTSIZE){
throw Exception("CMultiFileWatch::report_fd(): read() -> "+itos(r));
throw Exception("CFileWatch::report_fd(): read() -> "+itos(r));
}
struct inotify_event *in_event = (struct inotify_event*)buf;
ss_ name;
@ -150,9 +150,9 @@ struct CMultiFileWatch: MultiFileWatch
}
};
MultiFileWatch* createMultiFileWatch()
FileWatch* createFileWatch()
{
return new CMultiFileWatch();
return new CFileWatch();
}
}

View File

@ -7,20 +7,20 @@
namespace interface {
struct CMultiFileWatch: MultiFileWatch
struct CFileWatch: FileWatch
{
CMultiFileWatch()
CFileWatch()
{
log_e(MODULE, "CMultiFileWatch not implemented");
log_e(MODULE, "CFileWatch not implemented");
}
~CMultiFileWatch()
~CFileWatch()
{
}
void add(const ss_ &path, std::function<void(const ss_ &path)> cb)
{
log_e(MODULE, "CMultiFileWatch::add() not implemented");
log_e(MODULE, "CFileWatch::add() not implemented");
}
// Used on Linux; no-op on Windows
@ -35,13 +35,13 @@ struct CMultiFileWatch: MultiFileWatch
// Used on Windows; no-op on Linux
void update()
{
log_e(MODULE, "CMultiFileWatch::update() not implemented");
log_e(MODULE, "CFileWatch::update() not implemented");
}
};
MultiFileWatch* createMultiFileWatch()
FileWatch* createFileWatch()
{
return new CMultiFileWatch();
return new CFileWatch();
}
}

View File

@ -6,9 +6,9 @@
namespace interface
{
struct MultiFileWatch
struct FileWatch
{
virtual ~MultiFileWatch(){}
virtual ~FileWatch(){}
virtual void add(const ss_ &path,
std::function<void(const ss_ &path)> cb) = 0;
@ -22,6 +22,6 @@ namespace interface
};
// cb is called at either report_fd() or update().
MultiFileWatch* createMultiFileWatch();
FileWatch* createFileWatch();
}
// vim: set noet ts=4 sw=4:

View File

@ -219,7 +219,7 @@ struct CState: public State, public interface::Server
sm_<ss_, interface::ModuleInfo> m_module_info; // Info of every seen module
sm_<ss_, ModuleContainer> m_modules; // Currently loaded modules
set_<ss_> m_unloads_requested;
sm_<ss_, sp_<interface::MultiFileWatch>> m_module_file_watches;
sm_<ss_, sp_<interface::FileWatch>> m_module_file_watches;
// Module modifications are accumulated here and core:module_modified events
// are fired every event loop based on this to lump multiple modifications
// into one (generally a modification causes many notifications)
@ -377,7 +377,7 @@ struct CState: public State, public interface::Server
files_to_watch.insert(files_to_watch.end(), includes.begin(), includes.end());
if(m_module_file_watches.count(info.name) == 0){
sp_<interface::MultiFileWatch> w(interface::createMultiFileWatch());
sp_<interface::FileWatch> w(interface::createFileWatch());
for(const ss_ &watch_path : files_to_watch){
ss_ dir_path = interface::Filesystem::strip_file_name(watch_path);
w->add(dir_path, [this, info, watch_path](const ss_ &modified_path){