View Full Version : Question about VPatch
bluenet
17th October 2004, 06:37
When I use VPatch to patch a file, it will modified file CreationTime to LastWriteTime. I want to save the CreationTime so I search MSDN for GetFileTime and SetFileTime but not work.
My code:
FileOpen $1 "$INSTDIR\newfile.txt" r
System::Call '*(&i2, &i2) i .r0'
System::Call 'kernel32::GetFileTime(i, i, i, i) i (r1, r0,,) .r9'
vpatch::vpatchfile "$PLUGINSDIR\patch.pat" "$INSTDIR\oldfile.txt" "$INSTDIR\newfile.txt"
System::Call 'kernel32::SetFileTime(i, i, i, i) i (r1, r0,,) .r8'
System::Free $0
FileClose $1
StrCmp $8 0 +2
DetailPrint "Success!"
deguix
17th October 2004, 15:59
Try this one (as I didn't):
FileOpen $9 "$INSTDIR\newfile.txt" r
System::Call '*(i, i) i .r0'
System::Call '*(i, i) i .r1'
System::Call 'kernel32::GetFileTime(i, *l, *l, *l) i (r9, r0, r1,)'
FileClose $9
vpatch::vpatchfile "$PLUGINSDIR\patch.pat" "$INSTDIR\oldfile.txt" "$INSTDIR\newfile.txt"
FileOpen $9 "$INSTDIR\newfile.txt" r
System::Call 'kernel32::SetFileTime(i, *l, *l, *l) i (r9, r0, r1,) .r8'
System::Free $0
System::Free $1
FileClose $9
StrCmp $8 0 +2
DetailPrint "Success!"
bluenet
18th October 2004, 02:29
Tested, but not work :(
Comm@nder21
18th October 2004, 15:19
try this:
FileOpen $9 "$INSTDIR\newfile.txt" r
System::Call '*(i, i) i .r0'
System::Call '*(i, i) i .r1'
System::Call 'kernel32::GetFileTime(i, *l, *l, *l) i (r9, r0, r1,)'
FileClose $9
vpatch::vpatchfile "$PLUGINSDIR\patch.pat" "$INSTDIR\oldfile.txt" "$INSTDIR\newfile.txt"
FileOpen $9 "$INSTDIR\newfile.txt" w
System::Call 'kernel32::SetFileTime(i, *l, *l, *l) i (r9, r0, r1,) .r8'
System::Free $0
System::Free $1
FileClose $9
StrCmp $8 0 +2
DetailPrint "Success!"
bluenet
19th October 2004, 03:25
I modified VPatch source to save the FileTime, in vpatchdll.c header:
#include <Winbase.h>
FILETIME ftCreate, ftWrite;
and change:
result = DoPatch(hPatch, hSource, hDest);
to:
GetFileTime(hSource, &ftCreate, NULL, &ftWrite);
result = DoPatch(hPatch, hSource, hDest);
SetFileTime(hDest, &ftCreate, NULL, &ftWrite);
Comm@nder21's code I am not test, because modified the source is easy, I thinks. And the FileOpen w flags will destroy the newfile. thanks.
iceman_k
20th October 2004, 18:30
Modifying the source may be easy for now, but unless you submit it to Kichik for inclusion in CVS, either you are stuck with your modified version forever, with no updates or your modified version will be overwritten the next time you update NSIS.
Using the scripted method is a better solution, imo.
bluenet
21st October 2004, 04:08
OK. The modified plugins in attach file.
VPatch.dll is in "NSIS\Plugins"
Readme.html is in "NSIS\Contrib\VPatch"
vpatchdll.c is in "NSIS\Contrib\VPatch\Source\Plugin"
The vpatchfile function not change, and a new function SmartPatch add to keep the file time while patch. :)
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.