added /x switch for File and ReserveFile to exclude files and directories

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3783 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-11-26 17:18:10 +00:00
parent ee703bab52
commit 2a9a9ac72a
4 changed files with 31 additions and 10 deletions

View file

@ -14,6 +14,7 @@
#include "exehead/config.h"
#include <string>
#include <set>
#ifdef NSIS_SUPPORT_STANDARD_PREDEFINES
// Added by Sunil Kamath 11 June 2003
@ -145,7 +146,9 @@ class CEXEBuild {
int doCommand(int which_token, LineParser &line);
int do_add_file(const char *lgss, int attrib, int recurse, int *total_files, const char
*name_override=0, int generatecode=1, int *data_handle=0, std::string& basedir=std::string(""));
*name_override=0, int generatecode=1, int *data_handle=0,
const std::set<std::string>& excluded=std::set<std::string>(),
std::string& basedir=std::string(""));
int add_file(const std::string& dir, const std::string& file, int attrib, const char
*name_override, int generatecode, int *data_handle);
int do_add_file_create_dir(const std::string& local_dir, const std::string& dir, int attrib=0);

View file

@ -3978,6 +3978,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_FILE:
#ifdef NSIS_SUPPORT_FILE
{
set<string> excluded;
int a=1,attrib=0,rec=0,fatal=1;
if (!stricmp(line.gettoken_str(a),"/nonfatal")) {
fatal=0;
@ -4028,8 +4029,20 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK;
}
if (!strnicmp(line.gettoken_str(a),"/x",2))
{
while (!strnicmp(line.gettoken_str(a),"/x",2))
{
a++;
if (line.getnumtokens() < a+1) PRINTHELP()
excluded.insert(line.gettoken_str(a));
a++;
}
}
#ifdef _WIN32
else if (line.gettoken_str(a)[0] == '/') PRINTHELP()
if (line.gettoken_str(a)[0] == '/') PRINTHELP()
#endif
if (line.getnumtokens()<a+1) PRINTHELP()
while (a < line.getnumtokens())
@ -4047,10 +4060,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
}
int tf=0;
#ifdef _WIN32
int v=do_add_file(t, attrib, rec, &tf, NULL, which_token == TOK_FILE);
int v=do_add_file(t, attrib, rec, &tf, NULL, which_token == TOK_FILE, NULL, excluded);
#else
char *fn = my_convert(t);
int v=do_add_file(fn, attrib, rec, &tf, NULL, which_token == TOK_FILE);
int v=do_add_file(fn, attrib, rec, &tf, NULL, which_token == TOK_FILE, NULL, excluded);
my_convert_free(fn);
#endif
if (v != PS_OK) return v;
@ -5554,7 +5567,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
}
#ifdef NSIS_SUPPORT_FILE
int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int *total_files, const char *name_override, int generatecode, int *data_handle, string& basedir)
int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int *total_files, const char *name_override, int generatecode, int *data_handle, const set<string>& excluded, string& basedir)
{
assert(!name_override || !recurse);
@ -5573,6 +5586,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int *total
}
dir_reader *dr = new_dir_reader();
dr->exclude(excluded);
dr->read(dir);
dir_reader::iterator files_itr = dr->files().begin();
@ -5636,7 +5650,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int *total
const char *new_spec_c = new_spec.c_str();
if (do_add_file(new_spec_c, attrib, 1, total_files, NULL, generatecode, NULL, new_dir) != PS_OK) {
if (do_add_file(new_spec_c, attrib, 1, total_files, NULL, generatecode, NULL, excluded, new_dir) != PS_OK) {
delete dr;
return PS_ERROR;
}

View file

@ -77,10 +77,10 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_FINDCLOSE,"FindClose",1,0,"$(user_var: handle input)",TP_CODE},
{TOK_FINDFIRST,"FindFirst",3,0,"$(user_var: handle output) $(user_var: filename output) filespec",TP_CODE},
{TOK_FINDNEXT,"FindNext",2,0,"$(user_var: handle input) $(user_var: filename output)",TP_CODE},
{TOK_FILE,"File",1,-1,"[/nonfatal] [/a] ([/r] filespec [...]|/oname=outfile one_file_only)",TP_CODE},
{TOK_FILE,"File",1,-1,"[/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |\n /oname=outfile one_file_only)",TP_CODE},
{TOK_FILEBUFSIZE,"FileBufSize",1,0,"buf_size_mb",TP_ALL},
{TOK_FLUSHINI,"FlushINI",1,0,"ini_file",TP_CODE},
{TOK_RESERVEFILE,"ReserveFile",1,-1,"[/nonfatal] [/r] file [file...]",TP_ALL},
{TOK_RESERVEFILE,"ReserveFile",1,-1,"[/nonfatal] [/r] [/x filespec [...]] file [file...]",TP_ALL},
{TOK_FILECLOSE,"FileClose",1,0,"$(user_var: handle input)",TP_CODE},
{TOK_FILEERRORTEXT,"FileErrorText",0,2,"[text (can contain $0)] [text without ignore (can contain $0)]",TP_GLOBAL},
{TOK_FILEOPEN,"FileOpen",3,0,"$(user_var: handle output) filename openmode\n openmode=r|w|a",TP_CODE},