Adding new ${__FILEDIR__} preprocessor define containing directory of current script
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6108 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ab8f90f99e
commit
4d19aaa9ab
3 changed files with 33 additions and 5 deletions
|
@ -170,6 +170,10 @@ You can use these standard predefines to automatically add the build time to the
|
||||||
|
|
||||||
Current script name.
|
Current script name.
|
||||||
|
|
||||||
|
\S1{prefile} $\{__FILEDIR__\}
|
||||||
|
|
||||||
|
Current script directory.
|
||||||
|
|
||||||
\S1{preline} $\{__LINE__\}
|
\S1{preline} $\{__LINE__\}
|
||||||
|
|
||||||
Current line number.
|
Current line number.
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
|
#pragma comment(lib, "shlwapi.lib")
|
||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
#else
|
#else
|
||||||
# ifndef EXEHEAD
|
# ifndef EXEHEAD
|
||||||
|
|
|
@ -56,30 +56,52 @@ using namespace std;
|
||||||
// Added by Sunil Kamath 11 June 2003
|
// Added by Sunil Kamath 11 June 2003
|
||||||
TCHAR *CEXEBuild::set_file_predefine(const TCHAR *filename)
|
TCHAR *CEXEBuild::set_file_predefine(const TCHAR *filename)
|
||||||
{
|
{
|
||||||
|
TCHAR *oldfileinfo = NULL;
|
||||||
TCHAR *oldfilename = definedlist.find(_T("__FILE__"));
|
TCHAR *oldfilename = definedlist.find(_T("__FILE__"));
|
||||||
if(oldfilename)
|
TCHAR *oldfiledir = definedlist.find(_T("__FILEDIR__"));
|
||||||
|
if(oldfilename && oldfiledir)
|
||||||
{
|
{
|
||||||
oldfilename = _tcsdup(oldfilename);
|
oldfileinfo = new TCHAR[_tcslen(oldfilename)+_tcslen(oldfiledir)+2];
|
||||||
|
_tcscpy(oldfileinfo, oldfilename);
|
||||||
|
_tcscat(oldfileinfo, _T("|"));
|
||||||
|
_tcscat(oldfileinfo, oldfiledir);
|
||||||
definedlist.del(_T("__FILE__"));
|
definedlist.del(_T("__FILE__"));
|
||||||
|
definedlist.del(_T("__FILEDIR__"));
|
||||||
}
|
}
|
||||||
const TCHAR *p = _tcsrchr(filename,_T('\\'));
|
const TCHAR *p = _tcsrchr(filename,_T('\\'));
|
||||||
if(p) {
|
if(p) {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p = curfilename;
|
p = filename;
|
||||||
}
|
}
|
||||||
definedlist.add(_T("__FILE__"),p);
|
definedlist.add(_T("__FILE__"),p);
|
||||||
|
TCHAR dir[MAX_PATH];
|
||||||
|
#ifdef _WIN32
|
||||||
|
LPTSTR lpFilePart;
|
||||||
|
GetFullPathName(filename, COUNTOF(dir), dir, &lpFilePart);
|
||||||
|
PathRemoveFileSpec(dir);
|
||||||
|
#else
|
||||||
|
if (p == filename)
|
||||||
|
_tcscpy(dir, _T("."));
|
||||||
|
else
|
||||||
|
_tcsncpy(dir, filename, p-filename-1);
|
||||||
|
#endif
|
||||||
|
definedlist.add(_T("__FILEDIR__"),dir);
|
||||||
|
|
||||||
return oldfilename;
|
return oldfileinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::restore_file_predefine(TCHAR *oldfilename)
|
void CEXEBuild::restore_file_predefine(TCHAR *oldfilename)
|
||||||
{
|
{
|
||||||
|
definedlist.del(_T("__FILEDIR__"));
|
||||||
definedlist.del(_T("__FILE__"));
|
definedlist.del(_T("__FILE__"));
|
||||||
if(oldfilename) {
|
if(oldfilename) {
|
||||||
|
TCHAR *oldfiledir = _tcschr(oldfilename, _T('|'));
|
||||||
|
definedlist.add(_T("__FILEDIR__"),oldfiledir+1);
|
||||||
|
*oldfiledir = '\0';
|
||||||
definedlist.add(_T("__FILE__"),oldfilename);
|
definedlist.add(_T("__FILE__"),oldfilename);
|
||||||
free(oldfilename);
|
delete[] oldfilename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue