Skip to content

Commit

Permalink
#5440: Update last modification timestamp in MapResource after succes…
Browse files Browse the repository at this point in the history
…sful loading or saving
  • Loading branch information
codereader committed Dec 19, 2020
1 parent 2bd99ba commit b99f6e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions radiantcore/map/MapResource.cpp
Expand Up @@ -143,6 +143,8 @@ void MapResource::save(const MapFormatPtr& mapFormat)
// Save the actual file (throws on fail)
saveFile(*format, _mapRoot, scene::traverse, fullpath);

refreshLastModifiedTime();

mapSave();
}

Expand Down Expand Up @@ -309,6 +311,8 @@ RootNodePtr MapResource::loadMapNode()
loader.loadInfoFile(infoFileStream->getStream(), rootNode);
}
}

refreshLastModifiedTime();
}
catch (const OperationException& ex)
{
Expand All @@ -330,9 +334,6 @@ stream::MapResourceStream::Ptr MapResource::openFileStream(const std::string& pa
throw OperationException(fmt::format(_("Could not open file:\n{0}"), path));
}

// Remember the last modification time
_lastKnownModificationTime = fs::last_write_time(path);

return stream;
}

Expand All @@ -359,6 +360,17 @@ stream::MapResourceStream::Ptr MapResource::openInfofileStream()
}
}

void MapResource::refreshLastModifiedTime()
{
auto fullPath = getAbsoluteResourcePath();

if (os::fileOrDirExists(fullPath))
{
// Remember the last modified timestamp after a successful load
_lastKnownModificationTime = fs::last_write_time(fullPath);
}
}

std::string MapResource::GetInfoFileExtension()
{
std::string extension = game::current::getValue<std::string>(GKEY_INFO_FILE_EXTENSION);
Expand Down
1 change: 1 addition & 0 deletions radiantcore/map/MapResource.h
Expand Up @@ -79,6 +79,7 @@ class MapResource :
void constructPaths(const std::string& resourcePath);
std::string getAbsoluteResourcePath();

void refreshLastModifiedTime();
void mapSave();
void onMapChanged();

Expand Down

0 comments on commit b99f6e6

Please sign in to comment.