EgtGeneral 2.3l1 :

- in CopyFileEgt si copia esplicitamente la data di ultima modifica dal file originale.
This commit is contained in:
DarioS
2021-12-28 08:31:36 +01:00
parent e3fadcc54c
commit 714c4e1fba
2 changed files with 20 additions and 2 deletions
+20 -2
View File
@@ -15,7 +15,7 @@
#include "stdafx.h"
#include "\EgtDev\Include\EGnFileUtils.h"
#include "\EgtDev\Include\EGnStringUtils.h"
#include "\EgtDev\Include\EGtStringConverter.h"
#include "\EgtDev\Include\EgtStringConverter.h"
#include <io.h>
using namespace std ;
@@ -44,7 +44,25 @@ ExistsFile( const string& sFile)
bool
CopyFileEgt( const string& sFile, const string& sNewFile)
{
return ( ::CopyFileW( stringtoW( sFile), stringtoW( sNewFile), false) != 0) ;
// copio file
if ( ::CopyFileW( stringtoW( sFile), stringtoW( sNewFile), false) == 0)
return false ;
// recupero data ultima scrittura file sorgente
HANDLE hFile = CreateFileW( stringtoW( sFile), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL) ;
if ( hFile == INVALID_HANDLE_VALUE)
return true ;
FILETIME ftWrite ;
bool bOk = ( GetFileTime( hFile, NULL, NULL, &ftWrite) != FALSE) ;
CloseHandle( hFile) ;
if ( ! bOk)
return true ;
// scrivo data ultima scrittura file destinazione
HANDLE hNewFile = CreateFileW( stringtoW( sNewFile), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL) ;
if ( hNewFile == INVALID_HANDLE_VALUE)
return true ;
bool bNewOk = ( SetFileTime( hNewFile, NULL, NULL, &ftWrite) != FALSE) ;
CloseHandle( hNewFile) ;
return true ;
}
//-----------------------------------------------------------------------------