#12927 Add optional time threshold before creating ESMRY

When checking timestamp for ESMRY vs SMSPEC, allow ESMRY to be written before SMSPEC within a given limit in time difference.
This commit is contained in:
Magne Sjaastad committed 2025-10-07 12:18:03 +02:00
1 parent b321109904
commit e98bc867e4
6 files changed
+47 -10

No files matched your search

@@ -372,13 +372,18 @@ std::map<QString, QStringList> keyPathComponentsForEachFilePath( const QStringLi
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool isFirstOlderThanSecond( const std::string& firstFileName, const std::string& secondFileName )
bool isFirstOlderThanSecond( const std::string& firstFileName, const std::string& secondFileName, int timeThresholdInSeconds )
{
if ( !std::filesystem::exists( firstFileName ) || !std::filesystem::exists( secondFileName ) ) return false;
auto timeFirstFile = std::filesystem::last_write_time( firstFileName );
auto timeSecondFile = std::filesystem::last_write_time( secondFileName );
if ( timeThresholdInSeconds > 0 )
{
auto timeDiff = std::chrono::seconds( timeThresholdInSeconds );
timeFirstFile += timeDiff;
}
return ( timeFirstFile < timeSecondFile );
}