diff --git a/source/lib/res/res.cpp b/source/lib/res/res.cpp index a4b050a23c..612fb62e06 100755 --- a/source/lib/res/res.cpp +++ b/source/lib/res/res.cpp @@ -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); } diff --git a/source/lib/res/res.h b/source/lib/res/res.h index 7247133751..6bd19b406d 100755 --- a/source/lib/res/res.h +++ b/source/lib/res/res.h @@ -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(); diff --git a/source/lib/res/vfs.cpp b/source/lib/res/vfs.cpp index ca6a7756ff..80fa815abc 100755 --- a/source/lib/res/vfs.cpp +++ b/source/lib/res/vfs.cpp @@ -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)¶ms); #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)