Added !if /FileExists
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6170 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
a37905cc0c
commit
20dcb1923a
4 changed files with 37 additions and 2 deletions
|
@ -61,6 +61,7 @@ The opposite of !ifdef. The lines will be compiled when the gflag has not been d
|
|||
\S1{if} !if
|
||||
|
||||
\c [!] value [op value2]
|
||||
\c [!] /FileExists "c:\path\file.exe"
|
||||
|
||||
This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If value is non-zero, or the comparison of value and value2 depending on the operator results in true, the contained lines will be compiled. Otherwise, they will be skipped.
|
||||
op can be either == or != (string comparison), <=, < > or >= (float comparison), & (bitwise AND comparison), && or || (boolean comparison).
|
||||
|
@ -74,6 +75,10 @@ If [!] is set, return value will be switched from true to false and vice versa.
|
|||
\c !error "neither should this"
|
||||
\c !endif
|
||||
|
||||
\c !if /FileExists ".\cert.pfx"
|
||||
\c !finalize '".\sign.bat" "%1"'
|
||||
\c !endif
|
||||
|
||||
\S1{ifmacrodef} !ifmacrodef
|
||||
|
||||
\c gflag [bcheck gflag [...]]]
|
||||
|
|
|
@ -33,6 +33,10 @@ public:
|
|||
virtual const std::set<tstring>& files();
|
||||
virtual const std::set<tstring>& dirs();
|
||||
|
||||
// dir_reader always excludes . and .. AND the exclude list is private,
|
||||
// use this backdoor if you need to match "."
|
||||
virtual std::set<tstring>& hack_simpleexcluded() {return m_excluded;}
|
||||
|
||||
virtual void exclude(const tstring& spec);
|
||||
virtual void exclude(const std::set<tstring>& specs);
|
||||
|
||||
|
|
|
@ -486,7 +486,33 @@ parse_again:
|
|||
|
||||
if(line.getnumtokens() == 2)
|
||||
istrue = line.gettoken_int(1);
|
||||
|
||||
|
||||
else if (line.getnumtokens() == 3) {
|
||||
if (!_tcsicmp(line.gettoken_str(1),_T("/fileexists")))
|
||||
{
|
||||
TCHAR *fc = my_convert(line.gettoken_str(2));
|
||||
tstring dir = get_dir_name(fc), spec = get_file_name(fc);
|
||||
my_convert_free(fc);
|
||||
if (dir == spec) dir = _T(".");
|
||||
|
||||
boost::scoped_ptr<dir_reader> dr( new_dir_reader() );
|
||||
dr->hack_simpleexcluded().erase(_T("."));
|
||||
dr->read(dir);
|
||||
|
||||
for (dir_reader::iterator fit = dr->files().begin();
|
||||
fit != dr->files().end() && !istrue; fit++)
|
||||
{
|
||||
if (dir_reader::matches(*fit, spec)) istrue = true;
|
||||
}
|
||||
if (!istrue) for (dir_reader::iterator dit = dr->dirs().begin();
|
||||
dit != dr->dirs().end() && !istrue; dit++)
|
||||
{
|
||||
if (dir_reader::matches(*dit, spec)) istrue = true;
|
||||
}
|
||||
}
|
||||
else PRINTHELP()
|
||||
}
|
||||
|
||||
else if (line.getnumtokens() == 4) {
|
||||
mod = line.gettoken_enum(2,_T("=\0==\0!=\0<=\0<\0>\0>=\0&\0&&\0|\0||\0"));
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ static tokenType tokenlist[TOK__LAST] =
|
|||
{TOK_P_ADDINCLUDEDIR,_T("!AddIncludeDir"),1,0,_T("dir"),TP_ALL},
|
||||
{TOK_P_INCLUDE,_T("!include"),1,1,_T("[/NONFATAL] filename.nsh"),TP_ALL},
|
||||
{TOK_P_CD,_T("!cd"),1,0,_T("absolute_or_relative_new_directory"),TP_ALL},
|
||||
{TOK_P_IF,_T("!if"),1,3,_T("[!] value [(==,!=,<=,<,>,>=,&,&&,||) value2] [...]"),TP_ALL},
|
||||
{TOK_P_IF,_T("!if"),1,3,_T("[!] (value [(==,!=,<=,<,>,>=,&,&&,||) value2] | /FILEEXISTS path) [...]"),TP_ALL},
|
||||
{TOK_P_IFDEF,_T("!ifdef"),1,-1,_T("symbol [| symbol2 [& symbol3 [...]]]"),TP_ALL},
|
||||
{TOK_P_IFNDEF,_T("!ifndef"),1,-1,_T("symbol [| symbol2 [& symbol3 [...]]]"),TP_ALL},
|
||||
{TOK_P_ENDIF,_T("!endif"),0,0,_T(""),TP_ALL},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue