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:
parent
ee703bab52
commit
2a9a9ac72a
4 changed files with 31 additions and 10 deletions
|
@ -42,7 +42,7 @@ Execute the specified program and wait for the executed process to quit. See Exe
|
|||
|
||||
\S2{file} File
|
||||
|
||||
\c [/nonfatal] [/a] ([/r] (file|wildcard) [...] | /oname=file.dat infile.dat)
|
||||
\c [/nonfatal] [/a] ([/r] [/x file|wildcard [...]] (file|wildcard) [...] | /oname=file.dat infile.dat)
|
||||
|
||||
Adds file(s) to be extracted to the current output path ($OUTDIR).
|
||||
|
||||
|
@ -54,6 +54,8 @@ Adds file(s) to be extracted to the current output path ($OUTDIR).
|
|||
|
||||
\b If the /r switch is used, files and directories are added recursively. If there is no trailing wildcard (e.g. File /r C:\\whatever\\mydir), then the whole tree of mydir will go in $OUTDIR\\mydir. To put it in $OUTDIR, use File /r C:\\whatever\\mydir\\*.*
|
||||
|
||||
\b Use the /x switch to exclude files or directories.
|
||||
|
||||
\b If the /a switch is used, the attributes of the file(s) added will be preserved.
|
||||
|
||||
\b The File command sets the error flag if overwrite mode is set to 'try' and the file could not be overwritten, or if the overwrite mode is set to 'on' and the file could not be overwritten and the user selects ignore.
|
||||
|
@ -67,6 +69,8 @@ Adds file(s) to be extracted to the current output path ($OUTDIR).
|
|||
\c File /r data
|
||||
\c File /oname=$TEMP\temp.dat somefile.ext
|
||||
\c File /nonfatal "a file that might not exist"
|
||||
\c File /r /x CVS myproject
|
||||
\c File /r /x *.res /x *.obj /x *.pch source
|
||||
|
||||
\S2{rename} Rename
|
||||
|
||||
|
@ -80,7 +84,7 @@ If no absolute path is specified the current folder will be used. The current fo
|
|||
|
||||
\S2{reservefile} ReserveFile
|
||||
|
||||
\c [/nonfatal] [/r] file [file...]
|
||||
\c [/nonfatal] [/r] [/x file|wildcard [...]] file [file...]
|
||||
|
||||
Reserves a file in the data block for later use. Files are added to the compressed data block in the order they appear in the script. Functions, however, are not necessarily called in the order they appear in the script. Therefore, if you add a file in a function called early but put the function at the end of the script, all of the files added earlier will have to be decompressed to get to the required file. This process can take a long time if there a lot of files. \R{oninit}{.onInit} is one such function. It is called at the very beginning, before anything else appears. If you put it at the very end of the script, extract some files in it and have lots of files added before it, the installer might take a very long time to load. This is where this command comes useful, allowing you to speed up the loading process by including the file at the top of the data block instead of letting NSIS seek all the way down to the bottom of the \e{compressed} data block.
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue