mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 07:13:07 +01:00
Fix FileWatcher for Windows
This commit is contained in:
@@ -77,6 +77,7 @@ FileWatcher::WatchDescriptor::~WatchDescriptor()
|
||||
FileWatcher::FileWatcher(const std::string &directoryPath)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_path = directoryPath;
|
||||
_directoryHandle = CreateFileA(directoryPath.c_str(), FILE_LIST_DIRECTORY, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (_directoryHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -127,7 +128,8 @@ void FileWatcher::WatchDirectory()
|
||||
|
||||
std::wstring fileNameW(notifyInfo->FileName, notifyInfo->FileNameLength / sizeof(wchar_t));
|
||||
auto fileName = String::ToUtf8(fileNameW);
|
||||
onFileChanged(fileName);
|
||||
auto path = fs::path(_path) / fs::path(fileName);
|
||||
onFileChanged(path.u8string());
|
||||
}
|
||||
while (notifyInfo->NextEntryOffset != 0);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class FileWatcher
|
||||
private:
|
||||
std::thread _watchThread;
|
||||
#ifdef _WIN32
|
||||
std::string _path;
|
||||
HANDLE _directoryHandle{};
|
||||
#else
|
||||
struct FileDescriptor
|
||||
|
||||
@@ -114,7 +114,7 @@ void ScriptEngine::AutoReloadPlugins()
|
||||
auto findResult = std::find_if(_plugins.begin(), _plugins.end(),
|
||||
[&path](const std::shared_ptr<Plugin>& plugin)
|
||||
{
|
||||
return path == plugin->GetPath();
|
||||
return Path::Equals(path, plugin->GetPath());
|
||||
});
|
||||
if (findResult != _plugins.end())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user