Archive: File Append broken


File Append broken
I'm using the following code while in Silent mode (via /S). It's overwriting the log file instead of appending the data to it. My buggy code or something buggy with NSIS 2.45?


Function WriteErrorCode
Exch $0 ; message
Exch
Exch $1 ; error code
!define /date DATESTAMP "%Y-%m-%d %H:%M:%S"

SetOutPath $EXEDIR
FileOpen $9 $EXEDIR\Install_Errors.log a
FileWrite $9 "${DATESTAMP} - ErrorCode:$1 - $0$\r$\n"
FileClose $9
SetErrorLevel $1
Abort
FunctionEnd

;FileOpen
FileSeek $9 0 END
;FileWrite


I agree FileSeek should accomplish what I want. Isn't the point of the FileOpen append option to save the existing content and write the new at its end?


Isn't the point of the FileOpen append option to save the existing content and write the new at its end?
The manual says FileOpen's "a" mode means "append, meaning opened for both read and write, contents preserved". It then says
In all open modes, the file pointer is placed at the beginning of the file
See http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.2

Ah, assumed it would do that for me automatically. With the FileSeek, all works as expected after all. Thanks for the clarification and another round of RTFM ;)


I have lost count of how many times I have re-read the manual!