more abstraction in VFS<->dir watch interface (thinking of using dazuko and/or FAM)

This was SVN commit r594.
This commit is contained in:
janwas 2004-06-23 16:29:03 +00:00
parent 20211609c5
commit cc02e9ea97
3 changed files with 17 additions and 13 deletions

View file

@ -25,7 +25,7 @@ static bool initialized;
// path: portable and relative, must add current directory and convert to native
// better to use a cached string from rel_chdir - secure
int res_watch_dir(const char* const path, uint* const reqnum)
int res_watch_dir(const char* const path, uintptr_t* const watch)
{
if(!initialized)
{
@ -41,12 +41,12 @@ int res_watch_dir(const char* const path, uint* const reqnum)
if(FAMMonitorDirectory(&fc, n_full_path, &req, (void*)0) < 0)
return -1; // no way of getting error?
*reqnum = req.reqnum;
*watch = req.reqnum;
return 0;
}
int res_cancel_watch(const uint reqnum)
int res_cancel_watch(const uint watch)
{
if(!initialized)
{
@ -55,7 +55,7 @@ int res_cancel_watch(const uint reqnum)
}
FAMRequest req;
req.reqnum = reqnum;
req.reqnum = watch;
return FAMCancelMonitor(&fc, &req);
}

View file

@ -13,8 +13,8 @@ extern int res_reload(const char* fn);
// (wfam limitation)
extern int res_watch_dir(const char* const path, uint* const reqnum);
extern int res_watch_dir(const char* const path, uintptr_t* const watch);
extern int res_cancel_watch(const uint reqnum);
extern int res_cancel_watch(const uintptr_t watch);
extern int res_reload_changed_files();

View file

@ -40,11 +40,15 @@
// we add/cancel directory watches from the VFS mount code for convenience -
// it iterates through all subdirectories anyway (the watch code would need
// to do this, because FAM can't monitor a directory subtree) and provides
// storage for the FAM request number.
// define to disable that - removes request number from struct Dir,
// it iterates through all subdirectories anyway (*) and provides storage for
// a key to identify the watch (obviates separate Dir -> watch mapping).
//
// define this to strip out that code - removes .watch from struct Dir,
// and calls to res_watch_dir / res_cancel_watch.
//
// *: the add_watch code would need to iterate through subdirs and watch
// each one, because the monitor API (e.g. FAM) may only be able to
// watch single directories, instead of a whole subdirectory tree.
#undef NO_DIR_WATCH
@ -256,7 +260,7 @@ typedef SubDirs::iterator SubDirIt;
struct Dir
{
#ifndef NO_DIR_WATCH
uint watch_reqnum;
uintptr_t watch;
#endif
int add_file(const char* name, const FileLoc* loc);
@ -351,7 +355,7 @@ void Dir::clearR()
files.clear();
#ifndef NO_DIR_WATCH
res_cancel_watch(watch_reqnum);
res_cancel_watch(watch);
#endif
}
@ -524,7 +528,7 @@ static int tree_add_dirR(Dir* const dir, const char* const f_path, const FileLoc
file_enum(f_path, add_dirent_cb, (uintptr_t)&params);
#ifndef NO_DIR_WATCH
res_watch_dir(f_path, &dir->watch_reqnum);
res_watch_dir(f_path, &dir->watch);
#endif
for(SubDirIt it = dir->subdirs.begin(); it != dir->subdirs.end(); ++it)