From 3e15d2222bf725503ab5b5bd678b7eec6d9b29b8 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 12 Jun 2020 07:34:16 +0000 Subject: [PATCH] EgtGeneral 2.2f1 : - aggiunta funzione CompareFilesLastWriteTime. --- EgtGeneral.rc | Bin 11630 -> 11630 bytes FileUtils.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/EgtGeneral.rc b/EgtGeneral.rc index fca73edfb41dd40e2754f52ff67f633ebd4d6b20..67dff8eacea22db5c5e8f47929d272d8c40f6f05 100644 GIT binary patch delta 126 zcmaDC^)70|H#Sx?1|0^&&FjTZGfjRctTQ=4kYn;MP8sGjpdh1AI^*UBZYO5AB6DV_ Y#7Y)Su}sFzLDCKg#kfqAQ4Zn)08S|*0ssI2 delta 126 zcmaDC^)70|H#Sxi1|0_D&FjTZGfjRctTQ=4kYn;MP8sGDpdh1AI^*UBZYO5AB6DV_ Y#7Y)Su}sFzLDCKg#kfqAQ4Zn)08RNL0ssI2 diff --git a/FileUtils.cpp b/FileUtils.cpp index bee94c9..b09fdc8 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -61,6 +61,32 @@ EraseFile( const string& sFile) return ( ::DeleteFileW( stringtoW( sFile)) != 0) ; } +//----------------------------------------------------------------------------- +static bool +GetFileLastWriteTime( const string& sFile, FILETIME& ftWrite) +{ + HANDLE hFile = CreateFileW( stringtoW( sFile), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL) ; + if ( hFile == INVALID_HANDLE_VALUE) + return false ; + bool bOk = ( GetFileTime( hFile, NULL, NULL, &ftWrite) != FALSE) ; + CloseHandle( hFile) ; + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +CompareFilesLastWriteTime( const string& sFile1, const string& sFile2, int& nRes) +{ + FILETIME ftWrite1 ; + if ( ! GetFileLastWriteTime( sFile1, ftWrite1)) + return false ; + FILETIME ftWrite2 ; + if ( ! GetFileLastWriteTime( sFile2, ftWrite2)) + return false ; + nRes = CompareFileTime( &ftWrite1, &ftWrite2) ; + return true ; +} + //----------------------------------------------------------------------------- string ChangeFileExtension( const string& sFile, const string& sNewExt)