diff --git a/Docs/src/compiler.but b/Docs/src/compiler.but index 9d00cc4b..a4fb4311 100644 --- a/Docs/src/compiler.but +++ b/Docs/src/compiler.but @@ -33,6 +33,19 @@ Causes the NSIS compiler to scan the given directory for plug-in DLLs. \c !addplugindir myplugin \c MyPlugin::SomeFunction +\S1{appendfile} !appendfile + +\c file text + +Appends \e{text} to \e{file}. + +\c !tempfile FILE +\c !appendfile "${FILE}" "XPStyle on$\n" +\c !appendfile "${FILE}" "Name 'test'$\n" +\c !include "${FILE}" +\c !delfile "${FILE}" +\c !undef FILE + \S1{cd} !cd \c new_path diff --git a/Source/script.cpp b/Source/script.cpp index fcd18aa7..25f8773e 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -1069,6 +1069,30 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) SCRIPT_MSG("!delfile: \"%s\"\n", line.gettoken_str(1)); return PS_OK; + case TOK_P_APPENDFILE: + { + char *file = line.gettoken_str(1); + char *text = line.gettoken_str(2); + + FILE *fp = FOPEN(file, "a"); + if (!fp) + { + ERROR_MSG("!appendfile: \"%s\" couldn't be opened.\n", file); + return PS_ERROR; + } + + if (fputs(text, fp) < 0) + { + ERROR_MSG("!appendfile: error writing to \"%s\".\n", file); + return PS_ERROR; + } + + fclose(fp); + + SCRIPT_MSG("!appendfile: \"%s\" \"%s\"\n", file, text); + } + return PS_OK; + // page ordering shit /////////////////////////////////////////////////////////////////////////////// #ifdef NSIS_CONFIG_VISIBLE_SUPPORT diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 02a64049..c837925a 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -244,6 +244,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_P_TEMPFILE,"!tempfile",1,0,"symbol",TP_ALL}, {TOK_P_DELFILE,"!delfile",1,0,"file",TP_ALL}, +{TOK_P_APPENDFILE,"!appendfile",2,0,"file appended_line",TP_ALL}, {TOK_MISCBUTTONTEXT,"MiscButtonText",0,4,"[back button text] [next button text] [cancel button text] [close button text]",TP_GLOBAL}, {TOK_DETAILSBUTTONTEXT,"DetailsButtonText",0,1,"[details button text]",TP_PG}, diff --git a/Source/tokens.h b/Source/tokens.h index 9ec243f6..0919babd 100644 --- a/Source/tokens.h +++ b/Source/tokens.h @@ -97,6 +97,7 @@ enum TOK_P_TEMPFILE, TOK_P_DELFILE, + TOK_P_APPENDFILE, // section/function shit TOK_SECTION,