Refactored postbuild_cmd and !tempfile handling to help patch #280
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7025 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1d937a6abb
commit
cce4695977
6 changed files with 112 additions and 86 deletions
|
@ -740,6 +740,33 @@ char* create_file_view_readonly(const TCHAR *filepath, FILEVIEW&mmfv)
|
|||
#endif
|
||||
}
|
||||
|
||||
TCHAR* create_tempfile_path()
|
||||
{
|
||||
TCHAR *tfpath = NULL;
|
||||
#ifdef _WIN32
|
||||
TCHAR buftmpdir[MAX_PATH], buf[MAX_PATH];
|
||||
DWORD cch = GetTempPath(COUNTOF(buftmpdir), buftmpdir);
|
||||
if (cch && cch < COUNTOF(buftmpdir) && GetTempFileName(buftmpdir, _T("nst"), 0, buf))
|
||||
tfpath = _tcsdup(buf);
|
||||
#else //! _WIN32
|
||||
char narrowpath[] = ("/tmp/makensisXXXXXX");
|
||||
const mode_t org_umask = umask(0077);
|
||||
int fd = mkstemp(narrowpath);
|
||||
umask(org_umask);
|
||||
if (fd != -1)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
assert(NSISRT_free_is_STDC_free());
|
||||
tfpath = NSISRT_mbtowc(narrowpath);
|
||||
#else
|
||||
tfpath = _tcsdup(narrowpath);
|
||||
#endif
|
||||
close(fd);
|
||||
}
|
||||
#endif //~ _WIN32
|
||||
return tfpath;
|
||||
}
|
||||
|
||||
tstring get_full_path(const tstring &path) {
|
||||
#ifdef _WIN32
|
||||
TCHAR real_path[1024], *fnpart;
|
||||
|
@ -1156,12 +1183,6 @@ bool GetFileSize64(HANDLE hFile, ULARGE_INTEGER &uli)
|
|||
uli.LowPart = GetFileSize(hFile, &uli.HighPart);
|
||||
return INVALID_FILE_SIZE != uli.LowPart || !GetLastError();
|
||||
}
|
||||
static HANDLE NSISRT_GetConsoleScreenHandle()
|
||||
{
|
||||
DWORD cm;
|
||||
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
return GetConsoleMode(hCon, &cm) ? hCon : GetStdHandle(STD_ERROR_HANDLE);
|
||||
}
|
||||
#endif //~ _WIN32
|
||||
#if defined(_WIN32) && defined(_UNICODE) && defined(MAKENSIS)
|
||||
#include <io.h> // for _get_osfhandle
|
||||
|
@ -1272,6 +1293,12 @@ bool NSISRT_Initialize() // Init function for MakeNSIS Win32
|
|||
#elif defined(_WIN32)
|
||||
#define NSISRT_FastGetConsoleScreenHandle NSISRT_GetConsoleScreenHandle
|
||||
bool NSISRT_Initialize() { return true; } // Init function for non-MakeNSIS Win32 (NSISRT_DEFINEGLOBALS sets g_output and g_errout)
|
||||
static HANDLE NSISRT_GetConsoleScreenHandle()
|
||||
{
|
||||
DWORD cm;
|
||||
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
return GetConsoleMode(hCon, &cm) ? hCon : GetStdHandle(STD_ERROR_HANDLE);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PrintColorFmtErrMsg(const TCHAR *fmtstr, va_list args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue