Touch File: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Added category links.) |
mNo edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{ | {{PageAuthor|SamHasler}} | ||
== Description == | == Description == | ||
'''Requires:''' [[System]] | '''Requires:''' [[System plug-in|System]] plug-in. | ||
Changes the file modified date to the current date. | Changes the file modified date to the current date. | ||
Line 10: | Line 8: | ||
== Macro Call == | == Macro Call == | ||
<highlight-nsis> | <highlight-nsis> | ||
${Touch} | ${Touch} "[path/]file.ext" | ||
</highlight-nsis> | </highlight-nsis> | ||
Line 80: | Line 78: | ||
</highlight-nsis> | </highlight-nsis> | ||
[[ | [[Category:Disk, Path & File Functions]] |
Latest revision as of 07:50, 6 November 2005
Author: SamHasler (talk, contrib) |
Description
Requires: System plug-in.
Changes the file modified date to the current date.
Macro Call
${Touch} "[path/]file.ext"
The Function
;---------------------------------------------------------------------------- ; Title : Touch File ; Short Name : Touch ; Last Changed : 29/Mar/2005 ; Code Type : Function ; Code Sub-Type : Macro ;---------------------------------------------------------------------------- ; Requires : System plugin. ; Description : Changes the file modified date to the current date. ;---------------------------------------------------------------------------- ; Macro Call : ${Touch} "[path/]file.ext" ;---------------------------------------------------------------------------- ; Author : Sam Hasler ; Author Reg. Name : SamHasler ;---------------------------------------------------------------------------- Function Touch !define Touch `!insertmacro TouchCall` !macro TouchCall _FILE Push `${_FILE}` Call Touch !macroend Exch $0 # Get filename Push $1 Push $2 Push $3 DetailPrint "Touching $0" ClearErrors FileOpen $1 "$0" a IfErrors error # Big assumption: FileOpen handles are equivalent to # the handles used in system calls # i.e. those used by: # BOOL SetFileTime( # HANDLE hFile, # const FILETIME* lpCreationTime, # const FILETIME* lpLastAccessTime, # const FILETIME* lpLastWriteTime # ); System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) i .r2' System::Call 'kernel32::GetSystemTimeAsFileTime(i)i(r2)' System::Call 'kernel32::SetFileTime(i,i,i,i) i(r1,,,r2) .r3' System::Free $2 FileClose $1 IntCmp $3 -1 error goto end error: SetErrors MessageBox MB_OK "Failed to touch $0" end: pop $3 pop $2 pop $1 pop $0 FunctionEnd