Comments (10)
The function call order is wrong. The configuration should be done before adding the watch (when the flags are used).
void Game::LiveUpdate::Init()
{
filewatcher = std::make_shared<efsw::FileWatcher>();
fwlistener = std::make_shared<FSUpdateListener>();
filewatcher->followSymlinks(true);
filewatcher->allowOutOfScopeLinks(true);
watch_all = filewatcher->addWatch(wi::helper::GetCurrentPath(), fwlistener.get(), true);
filewatcher->watch();
}
from efsw.
Yeah, it works now, thanks 👍
from efsw.
Already set the option for both followSymlinks and allowOutOfScopeLinks to true.
from efsw.
Folders too
from efsw.
Hi! What file system are you using? Is it a network file system (NFS, SMB)?
from efsw.
I use ext4 on Linux.
from efsw.
I think I'll need a minimum example to be able to reproduce it. I'm on the same setup and works just fine with the efsw test using followSymlinks and allowOutOfScopeLinks enabled and adding a symlink to a folder out of scope. If possible try to provide an example that creates that symlink and writes a file to the symlinked folder. Thanks.
from efsw.
So first, this is the code I'm writing for checking file changes:
struct FSEvent{
enum TYPE{
ADD,
MODIFY,
DELETE
};
TYPE type;
std::string filetype;
std::string filepath;
};
wi::unordered_map<std::string, FSEvent> fsevents;
std::mutex event_sync;
class FSUpdateListener : public efsw::FileWatchListener
{
void handleFileAction(efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename) override
{
bool store = false;
FSEvent::TYPE action_type;
switch(action){
case efsw::Actions::Add:
{
store = true;
action_type = FSEvent::ADD;
break;
}
case efsw::Actions::Modified:
{
store = true;
action_type = FSEvent::MODIFY;
break;
}
case efsw::Actions::Delete:
{
store = true;
action_type = FSEvent::DELETE;
break;
}
default:
break;
}
std::scoped_lock lock (event_sync);
fsevents[filename] = {
action_type,
wi::helper::toUpper(wi::helper::GetExtensionFromFileName(filename)),
dir+filename,
};
}
};
std::shared_ptr<efsw::FileWatcher> filewatcher;
std::shared_ptr<FSUpdateListener> fwlistener;
efsw::WatchID watch_all;
void Game::LiveUpdate::Init()
{
filewatcher = std::make_shared<efsw::FileWatcher>();
fwlistener = std::make_shared<FSUpdateListener>();
watch_all = filewatcher->addWatch(wi::helper::GetCurrentPath(), fwlistener.get(), true);
filewatcher->watch();
}
void Game::LiveUpdate::Update(float dt)
{
std::scoped_lock lock (event_sync);
for(auto& pair_event : fsevents){
wi::backlog::post("wiix");
auto& event = pair_event.second;
if(event.filetype == "LUA"){
Game::ScriptBindings::LiveUpdate::PushEvent({
(event.type == FSEvent::DELETE) ? Game::ScriptBindings::LiveUpdate::ScriptReloadEvent::UNLOAD : Game::ScriptBindings::LiveUpdate::ScriptReloadEvent::RELOAD,
Game::ScriptBindings::LiveUpdate::ScriptReloadEvent::LUA,
event.filepath
});
}
}
fsevents.clear();
Resources::LiveUpdate::Update(dt);
ScriptBindings::LiveUpdate::Update(dt);
}
Second, this is the file structure:
Program
script.lua <-- symlink to a file out of scope
Expected behavior: Program detects changes to the symlink file after the file is updated (saved over) from a text editor.
What happened instead: Program does not detect file changes at all.
If i have a folder that is symlinked like this:
Program
FolderX <-- symlink to a folder out of scope
|-- script.lua
symlink is using ln -s script.lua
The result is the same, it won't react to the change at all.
Does efsw needs some specific file/folder flags for symlinked ones to work?
Atleast for non symlink with those two structures above is working for me.
For the full repo i have it in here: https://github.com/megumumpkin/WickedEngine-Demo/
The code mentioned above is from LiveUpdate.cpp from Sources/ folder
Program ran from build/ folder (exists after bulding)
from efsw.
Oh.
The first example shouldn't return any event, since the file descriptor of the symlink isn't modified, what's being modified is the file that it's being linked to. In that case, you will need to manually detect symlink files and add the folder that contains the real file. This is not a limitation of the library but how the file system works.
The second example I'm not sure if I understand you, but, if the only symlink is the folder FolderX
and script.lua
is an actual file, it should work, but if script.lua
is also a symlink, the same issue should happen.
from efsw.
So I set up the liveupdate tracking like this:
void Game::LiveUpdate::Init()
{
filewatcher = std::make_shared<efsw::FileWatcher>();
fwlistener = std::make_shared<FSUpdateListener>();
watch_all = filewatcher->addWatch(wi::helper::GetCurrentPath(), fwlistener.get(), true);
filewatcher->followSymlinks(true);
filewatcher->allowOutOfScopeLinks(true);
filewatcher->watch();
}
Trying out the 2nd case, and it does not detect too.
For file links it needs to be hardlink and not symlink, and has to edit the hardlinked one, not the source it seems.
from efsw.
Related Issues (20)
- How to use QT-Creator to open the project 'qtreator-win' ? HOT 2
- Monitor multiple files failures under Windows HOT 6
- Generic watcher fails to watch sub-sub directories HOT 6
- Filename passed without extension HOT 1
- Bazel Building HOT 1
- On MacOS, actions happening shortly after starting watcher are not reported HOT 19
- CMake multi config issue HOT 2
- Support Windows long path aware HOT 4
- Check Return Code and Allow Buffer Customization in `ReadDirectoryChangesW()` Function HOT 1
- Paranoid exit code? HOT 2
- MacOS build on server HOT 1
- [Bug] Crash while thread running after FileWatcherInotfiy destructed. HOT 16
- Premake5 macosx after gmake2 ... [CI Server] HOT 1
- Last modified file remembered and failing to fire event under Windows HOT 5
- Premake links in ReadMe is dead HOT 1
- FSEventStreamScheduleWithRunLoop has been deprecated in MacOS 13 HOT 3
- Nested template syntax breaks LEGACY builds HOT 3
- Generic file watcher doesn't report new directories on network drives HOT 2
- memory leak doubt and thread conflict HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efsw.