Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Utility::FileWatcher watching wrong filepath when using with Utility::Tweakable on Linux #61
When trying to use CORRADE_TWEAKABLE() with Utility::Tweakable I get a runtime error message from Utility::FileWatcher on Linux
I believe the root / was not inserted at the begin of the filepath string causing the filepath to be relative instead of absolute and the file not to be found.
Hi! The path is gathered from the
cd / g++ home/ad/CLionProjects/MagnumProject/src/MyApplication.cpp -o MyApplication
then you'll get the path without the initial slash in
There's the Tweakable::enable(const std::string&, const std::string&) overload that allows you to set the path prefix explicitly, it's there to cover exactly these cases. From the top of my head, I think calling
could do the trick. Hope this helps! :)
Oh, okay, thanks for the heads-up!
Is it possible for you to try the following patch (and running with just the argument-less
diff --git a/src/Corrade/Utility/Tweakable.cpp b/src/Corrade/Utility/Tweakable.cpp index 8e0f8b7c..f51d847d 100644 --- a/src/Corrade/Utility/Tweakable.cpp +++ b/src/Corrade/Utility/Tweakable.cpp @@ -110,7 +110,7 @@ std::pair<bool, void*> Tweakable::registerVariable(const char* const file, const works correctly. */ /** @todo maybe some Directory utility for this? */ std::string stripped = String::stripPrefix(Directory::fromNativeSeparators(file), _data->prefix); - if(!stripped.empty() && stripped.front() == '/') + if(!_data->prefix.empty() && !stripped.empty() && stripped.front() == '/') stripped.erase(0, 1); const std::string watchPath = Directory::join(_data->replace, stripped);
Thanks a lot!