I want to make a backup copy of file only in case when it is different from installed version and then overwrite it.
Here is a macro I wrote to do this:
but generally it does not work.!macro CopyFileEx LOCAL_DIR DEST_DIR FILE_NAME
SetOverwrite ifdiff
DetailPrint "Backup file path ${DEST_DIR}${FILE_NAME}.old"
GetFileTimeLocal "${LOCAL_DIR}${FILE_NAME}" $R0 $R1
IfFileExists ${FILE_NAME} 0 +10
GetFileTime ${FILE_NAME} $R2 $R3
DetailPrint "LOW_LOCAL=$R1 LOW=$R3 HIGH_LOCAL=$R0 HIGH=$R2"
IntCmp $R0 $R2 0 +4 +4
DetailPrint "HIGH_LOCAL=$R0 equal HIGH=$R2"
IntCmp $R1 $R3 +5 0 0
DetailPrint "LOW_LOCAL=$R1 not equal LOW=$R3"
IfFileExists "${FILE_NAME}.old" 0 +2
Delete "${DEST_DIR}${FILE_NAME}.old"
Rename "${FILE_NAME}" "${FILE_NAME}.old"
File "${LOCAL_DIR}${FILE_NAME}"
;nothing changed
!macroend
!insertmacro CopyFileEx "${_DATA_DIR}\syntax\" "$INSTDIR\data\" "xml_user.xml"
File time is always different (event after reinstall),
existing .old files are not deleted and rename in this case does not work, File command says skipped even when file time read from GetFileTime and GetFileTimeLocal is different.
For me coding looks correct and I dont know what to check more.
Maybe some has idea how to make this working or maybe better solutions for backup of files which differ exist?
Thanks a lot for help!
Regards,
Kefira