jaswolf
7th March 2006 21:51 UTC
NSIS and Touch
I'm a novice at this and am trying touch a single file when executing the installer I'm creating using NSIS. I want this single file to show the install date as the "last modified" so that I know when it was installed (I don't want to use SetDateSave because that changes the date on all the files). Has anyone had success doing this sort of thing?
kichik
7th March 2006 21:59 UTC
You can open it and close it right away with FileOpen and FileClose.
dandaman32
8th March 2006 02:20 UTC
You can open it and close it right away with FileOpen and FileClose.
Make sure to make the open mode "a" (as opposed to "r" or "w") because "r" will only open the file for reading, and "w" will wipe the file clean.
FileOpen $0 "$INSTDIR\replace_with_file.name" a
FileClose $0
      
      -dandaman32
    
      jaswolf
      8th March 2006 17:58 UTC
      I try putting that in a fuction and get a 'install function "TouchFile" not referenced - zeroing code (0-4) out
      ' error.
      
      Function TouchFile
      FileOpen $0 $INSTDIR\test.txt a
      FileClose $0
      FunctionEnd
     
    
      dandaman32
      8th March 2006 19:20 UTC
      Here's what you're looking for:
      
Function TouchFile
  Exch $0
  Push $1
  FileOpen $1 $0 a
  FileClose $1
  Pop $1
  Exch $0
FunctionEnd
      ...and later, in your sections...
      
Push "$INSTDIR\text.txt"
Call TouchFile
      
      -dandaman32
    
 
    
      Jamyn
      9th March 2006 08:31 UTC
      Someone has already written a pretty nice function for "touch". This might be interesting to you.
     
    
      jaswolf
      9th March 2006 22:28 UTC
      Had tried that Touch function before w/o success, but went back an made it work pretty well with using under a "Function .onGUIEnd" section. Thanks for all the input.