Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 17th October 2004, 06:37   #1
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
Question about VPatch

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!"
bluenet is offline   Reply With Quote
Old 17th October 2004, 15:59   #2
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,353
Send a message via ICQ to deguix
Try this one (as I didn't):

code:
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!"


My Wiki Pages

Working now on:
New projects. (language: any)

Last edited by deguix; 17th October 2004 at 16:20.
deguix is offline   Reply With Quote
Old 18th October 2004, 02:29   #3
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
Tested, but not work
bluenet is offline   Reply With Quote
Old 18th October 2004, 15:19   #4
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
try this:
code:
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!"

Comm@nder21 is offline   Reply With Quote
Old 19th October 2004, 03:25   #5
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
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.

Last edited by bluenet; 19th October 2004 at 04:01.
bluenet is offline   Reply With Quote
Old 20th October 2004, 18:30   #6
iceman_k
NSIS Dev
 
iceman_k's Avatar
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
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.

Cheers,
Iceman_K

EclipseNSIS - An NSIS IDE for the Eclipse Platform | My contributions to the wiki
iceman_k is offline   Reply With Quote
Old 21st October 2004, 04:08   #7
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
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.
Attached Files
File Type: zip vpatch.zip (7.7 KB, 63 views)
bluenet is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump