SaveTool: fix an issue with the file watcher.

Closes #32.
This commit is contained in:
Guillaume Jacquemin 2023-10-29 16:46:08 +01:00
parent 066ce6ac70
commit 9e7547a1cd

View file

@ -49,7 +49,9 @@ SaveTool::handleFileAction(efsw::WatchID watch_id,
return;
} // TODO: actually do something when config files will finally be handled
if(!Utility::String::endsWith(filename, Utility::format("Profile{}.sav", _currentProfile->account()).data())) {
if(!Utility::String::endsWith(filename, Utility::format("Profile{}.sav", _currentProfile->account()).data()) &&
filename.find("Unit") == std::string::npos)
{
return;
}
@ -83,7 +85,8 @@ SaveTool::fileUpdateEvent(SDL_Event& event) {
}
if(event.user.code == FileMoved) {
old_filename = Containers::String{static_cast<char*>(event.user.data2), std::strlen(static_cast<char*>(event.user.data2)), nullptr};
old_filename = Containers::String{static_cast<char*>(event.user.data2),
std::strlen(static_cast<char*>(event.user.data2)), nullptr};
old_index = ((old_filename[_currentProfile->isDemo() ? 8 : 4] - 0x30) * 10) +
(old_filename[_currentProfile->isDemo() ? 9 : 5] - 0x30);
}
@ -125,8 +128,8 @@ SaveTool::fileUpdateEvent(SDL_Event& event) {
}
else {
if(_modifiedBySaveTool && _currentMass->filename() == filename) {
auto handle = CreateFileW(Utility::Unicode::widen(Containers::StringView{filename}), GENERIC_READ, 0,
nullptr, OPEN_EXISTING, 0, nullptr);
auto handle = CreateFileW(Utility::Unicode::widen(Containers::StringView{filename}),
GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if(handle && handle != INVALID_HANDLE_VALUE) {
CloseHandle(handle);
_modifiedBySaveTool = false;