- auto conversion of paths on POSIX platforms - based on patch #1005673
- LoadLanguageFile error message improvement git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3636 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
827b69fbb5
commit
98caca8be1
8 changed files with 184 additions and 51 deletions
|
@ -49,14 +49,20 @@ typedef unsigned long HBRUSH;
|
|||
typedef WORD LANGID;
|
||||
#endif
|
||||
|
||||
// system specific
|
||||
|
||||
#ifdef _WIN32
|
||||
// script path separator
|
||||
|
||||
# define PATH_SEPARATOR_STR "\\"
|
||||
# define PATH_SEPARATOR_C '\\'
|
||||
|
||||
// system specific separator
|
||||
|
||||
#ifdef _WIN32
|
||||
# define PLATFORM_PATH_SEPARATOR_STR "\\"
|
||||
# define PLATFORM_PATH_SEPARATOR_C '\\'
|
||||
#else
|
||||
# define PATH_SEPARATOR_STR "/"
|
||||
# define PATH_SEPARATOR_C '/'
|
||||
# define PLATFORM_PATH_SEPARATOR_STR "/"
|
||||
# define PLATFORM_PATH_SEPARATOR_C '/'
|
||||
#endif
|
||||
|
||||
// attributes
|
||||
|
|
|
@ -34,7 +34,7 @@ void Plugins::FindCommands(char* path, bool displayInfo)
|
|||
|
||||
char* pathAndWildcard = new char [length+7];
|
||||
strcpy(pathAndWildcard,basePath);
|
||||
strcat(pathAndWildcard,PATH_SEPARATOR_STR "*.dll");
|
||||
strcat(pathAndWildcard,PLATFORM_PATH_SEPARATOR_STR "*.dll");
|
||||
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA data;
|
||||
|
@ -59,7 +59,7 @@ void Plugins::FindCommands(char* path, bool displayInfo)
|
|||
#ifdef _WIN32
|
||||
{
|
||||
char* dllPath = new char [length+strlen(data.cFileName)+2];
|
||||
wsprintf(dllPath,"%s" PATH_SEPARATOR_STR "%s",basePath,data.cFileName);
|
||||
wsprintf(dllPath,"%s" PLATFORM_PATH_SEPARATOR_STR "%s",basePath,data.cFileName);
|
||||
#else
|
||||
char *dllPath = new char [strlen(globbuf.gl_pathv[i])+1];
|
||||
strcpy(dllPath,globbuf.gl_pathv[i]);
|
||||
|
@ -93,7 +93,7 @@ void Plugins::GetExports(char* pathToDll, bool displayInfo)
|
|||
char signature[1024];
|
||||
|
||||
dllName[0] = 0;
|
||||
char* ptr = strrchr(pathToDll,PATH_SEPARATOR_C);
|
||||
char* ptr = strrchr(pathToDll,PLATFORM_PATH_SEPARATOR_C);
|
||||
if (ptr && *ptr && *(ptr+1)) strcpy(dllName,ptr+1);
|
||||
|
||||
// find .dll
|
||||
|
|
|
@ -478,7 +478,7 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS");
|
|||
void CEXEBuild::setdirs(char *argv0)
|
||||
{
|
||||
char szNSISDir[NSIS_MAX_STRLEN*2],*fn2;
|
||||
int len = sizeof(szNSISDir) - sizeof(PATH_SEPARATOR_STR "Include") - 1;
|
||||
int len = sizeof(szNSISDir) - sizeof(PLATFORM_PATH_SEPARATOR_STR "Include") - 1;
|
||||
#ifdef _WIN32
|
||||
GetModuleFileName(NULL,szNSISDir,len);
|
||||
#else
|
||||
|
@ -487,10 +487,10 @@ void CEXEBuild::setdirs(char *argv0)
|
|||
szNSISDir[sizeof(szNSISDir)-1] = 0;
|
||||
my_free_realpath(argv0, buffer);
|
||||
#endif
|
||||
fn2=strrchr(szNSISDir,PATH_SEPARATOR_C);
|
||||
fn2=strrchr(szNSISDir,PLATFORM_PATH_SEPARATOR_C);
|
||||
if(fn2!=NULL) *fn2=0;
|
||||
definedlist.add("NSISDIR",(char*)szNSISDir);
|
||||
strcat(szNSISDir, PATH_SEPARATOR_STR "Include");
|
||||
strcat(szNSISDir, PLATFORM_PATH_SEPARATOR_STR "Include");
|
||||
include_dirs.add(szNSISDir,0);
|
||||
}
|
||||
|
||||
|
@ -2322,7 +2322,7 @@ int CEXEBuild::write_output(void)
|
|||
// Pack exe header if asked for
|
||||
if (build_packname[0] && build_packcmd[0])
|
||||
{
|
||||
FILE *tmpfile=fopen(build_packname,"wb");
|
||||
FILE *tmpfile=FOPEN(build_packname,"wb");
|
||||
if (!tmpfile)
|
||||
{
|
||||
ERROR_MSG("Error: writing temporary file \"%s\" for pack\n",build_packname);
|
||||
|
@ -2336,7 +2336,7 @@ int CEXEBuild::write_output(void)
|
|||
ERROR_MSG("Error: calling packer on \"%s\"\n",build_packname);
|
||||
return PS_ERROR;
|
||||
}
|
||||
tmpfile=fopen(build_packname,"rb");
|
||||
tmpfile=FOPEN(build_packname,"rb");
|
||||
if (!tmpfile)
|
||||
{
|
||||
remove(build_packname);
|
||||
|
@ -2389,7 +2389,7 @@ int CEXEBuild::write_output(void)
|
|||
my_free_realpath(build_output_filename, buffer);
|
||||
#endif
|
||||
}
|
||||
FILE *fp = fopen(build_output_filename,"w+b");
|
||||
FILE *fp = FOPEN(build_output_filename,"w+b");
|
||||
if (!fp)
|
||||
{
|
||||
ERROR_MSG("Can't open output file\n");
|
||||
|
@ -2451,7 +2451,7 @@ int CEXEBuild::write_output(void)
|
|||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||
if (build_compress_whole)
|
||||
{
|
||||
int n;
|
||||
int n;
|
||||
if (compressor == &lzma_compressor)
|
||||
n = ((CLZMA *) compressor)->Init(build_compress_level, build_compress_dict_size);
|
||||
else
|
||||
|
@ -3176,8 +3176,8 @@ void CEXEBuild::build_plugin_table(void)
|
|||
char* searchPath = new char [strlen(nsisdir)+9];
|
||||
if (searchPath)
|
||||
{
|
||||
sprintf(searchPath,"%s" PATH_SEPARATOR_STR "Plugins",nsisdir);
|
||||
INFO_MSG("Processing plugin dlls: \"%s" PATH_SEPARATOR_STR "*.dll\"\n",searchPath);
|
||||
sprintf(searchPath,"%s" PLATFORM_PATH_SEPARATOR_STR "Plugins",nsisdir);
|
||||
INFO_MSG("Processing plugin dlls: \"%s" PLATFORM_PATH_SEPARATOR_STR "*.dll\"\n",searchPath);
|
||||
m_plugins.FindCommands(searchPath,display_info?true:false);
|
||||
INFO_MSG("\n");
|
||||
delete[] searchPath;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "build.h"
|
||||
#include "util.h"
|
||||
#include "DialogTemplate.h"
|
||||
#include "exehead/resource.h"
|
||||
|
||||
|
@ -730,9 +731,9 @@ BOOL IsValidCodePage(UINT CodePage)
|
|||
|
||||
// NSIS Language File parser
|
||||
LanguageTable * CEXEBuild::LoadLangFile(char *filename) {
|
||||
FILE *f = fopen(filename, "r");
|
||||
FILE *f = FOPEN(filename, "r");
|
||||
if (!f) {
|
||||
ERROR_MSG("Error: Can't open language file!\n");
|
||||
ERROR_MSG("Error: Can't open language file - \"%s\"!\n",filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ int main(int argc, char **argv)
|
|||
exepath[1023]=0;
|
||||
char *p=exepath;
|
||||
while (*p) p++;
|
||||
while (p > exepath && *p != PATH_SEPARATOR_C) p=CharPrev(exepath,p);
|
||||
while (p > exepath && *p != PLATFORM_PATH_SEPARATOR_C) p=CharPrev(exepath,p);
|
||||
if (p>exepath) p++;
|
||||
strcpy(p,"nsisconf.nsh");
|
||||
FILE *cfg=fopen(exepath,"rt");
|
||||
|
@ -336,10 +336,10 @@ int main(int argc, char **argv)
|
|||
p=CharPrev(dirbuf,p);
|
||||
#else
|
||||
getcwd(dirbuf,sizeof(dirbuf)-strlen(sfile)-2);
|
||||
if (dirbuf[strlen(dirbuf)-1]!=PATH_SEPARATOR_C)
|
||||
strcat(dirbuf,PATH_SEPARATOR_STR);
|
||||
if (dirbuf[strlen(dirbuf)-1]!=PLATFORM_PATH_SEPARATOR_C)
|
||||
strcat(dirbuf,PLATFORM_PATH_SEPARATOR_STR);
|
||||
strcat(dirbuf,sfile);
|
||||
p=strrchr(dirbuf,PATH_SEPARATOR_C);
|
||||
p=strrchr(dirbuf,PLATFORM_PATH_SEPARATOR_C);
|
||||
#endif
|
||||
if (!p) p=dirbuf;
|
||||
*p=0;
|
||||
|
|
|
@ -634,7 +634,7 @@ int CEXEBuild::parseScript()
|
|||
int CEXEBuild::includeScript(char *f)
|
||||
{
|
||||
SCRIPT_MSG("!include: \"%s\"\n",f);
|
||||
FILE *incfp=fopen(f,"rt");
|
||||
FILE *incfp=FOPEN(f,"rt");
|
||||
if (!incfp)
|
||||
{
|
||||
ERROR_MSG("!include: could not open file: \"%s\"\n",f);
|
||||
|
@ -1335,7 +1335,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
|
||||
FILE *fp;
|
||||
unsigned int datalen;
|
||||
fp=fopen(file,"rb");
|
||||
fp=FOPEN(file,"rb");
|
||||
if (!fp)
|
||||
{
|
||||
ERROR_MSG("LicenseLangString: open failed \"%s\"\n",file);
|
||||
|
@ -1643,7 +1643,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
if (!idx)
|
||||
{
|
||||
unsigned int datalen;
|
||||
FILE *fp=fopen(file,"rb");
|
||||
FILE *fp=FOPEN(file,"rb");
|
||||
if (!fp)
|
||||
{
|
||||
ERROR_MSG("LicenseData: open failed \"%s\"\n",file);
|
||||
|
@ -2196,7 +2196,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
int k=line.gettoken_enum(1, "all\0IDD_LICENSE\0IDD_DIR\0IDD_SELCOM\0IDD_INST\0IDD_INSTFILES\0IDD_UNINST\0IDD_VERIFY\0IDD_LICENSE_FSRB\0IDD_LICENSE_FSCB\0");
|
||||
if (k<0) PRINTHELP();
|
||||
|
||||
FILE *fui = fopen(line.gettoken_str(2), "rb");
|
||||
FILE *fui = FOPEN(line.gettoken_str(2), "rb");
|
||||
if (!fui) {
|
||||
ERROR_MSG("Error: Can't open \"%s\"!\n", line.gettoken_str(2));
|
||||
return PS_ERROR;
|
||||
|
@ -2589,7 +2589,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
int cmpv=line.gettoken_int(3,&success);
|
||||
if (!success && comp != 4) PRINTHELP()
|
||||
SCRIPT_MSG("!system: \"%s\"\n",exec);
|
||||
#ifdef _WIN32
|
||||
int ret=system(exec);
|
||||
#else
|
||||
char *execfixed = my_convert(exec);
|
||||
int ret=system(execfixed);
|
||||
my_convert_free(execfixed);
|
||||
#endif
|
||||
if (comp == 0 && ret < cmpv);
|
||||
else if (comp == 1 && ret > cmpv);
|
||||
else if (comp == 2 && ret != cmpv);
|
||||
|
@ -2616,7 +2622,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
#else
|
||||
system(exec);
|
||||
char *execfixed = my_convert(exec);
|
||||
system(execfixed);
|
||||
my_convert_free(execfixed);
|
||||
#endif
|
||||
SCRIPT_MSG("!execute: \"%s\"\n",exec);
|
||||
}
|
||||
|
@ -2652,7 +2660,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
char *incfile = (char *) malloc(malloced);
|
||||
strcpy(incfile, f);
|
||||
glob_t globbuf;
|
||||
if (!glob(incfile, GLOB_NOSORT, NULL, &globbuf))
|
||||
if (!GLOB(incfile, GLOB_NOSORT, NULL, &globbuf))
|
||||
{
|
||||
for (unsigned int i = 0; i < globbuf.gl_pathc; i++)
|
||||
{
|
||||
|
@ -2700,7 +2708,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
|
||||
if (includeScript(incfile) != PS_OK)
|
||||
#else
|
||||
if (!glob(incfile, GLOB_NOSORT, NULL, &globbuf))
|
||||
if (!GLOB(incfile, GLOB_NOSORT, NULL, &globbuf))
|
||||
{
|
||||
for (unsigned int i = 0; i < globbuf.gl_pathc; i++)
|
||||
{
|
||||
|
@ -4021,7 +4029,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
if (!*on||line.getnumtokens()!=a+1||strstr(on,"*") || strstr(on,"?")) PRINTHELP()
|
||||
|
||||
int tf=0;
|
||||
#ifdef _WIN32
|
||||
int v=do_add_file(line.gettoken_str(a), attrib, 0, linecnt,&tf,on);
|
||||
#else
|
||||
char *fn = my_convert(line.gettoken_str(a));
|
||||
int v=do_add_file(fn, attrib, 0, linecnt,&tf,on);
|
||||
my_convert_free(fn);
|
||||
#endif
|
||||
if (v != PS_OK) return v;
|
||||
if (tf > 1) PRINTHELP()
|
||||
if (!tf)
|
||||
|
@ -4039,11 +4053,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
|
||||
return PS_OK;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if (line.gettoken_str(a)[0] == '/') PRINTHELP()
|
||||
#endif
|
||||
if (line.getnumtokens()<a+1) PRINTHELP()
|
||||
while (a < line.getnumtokens())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (line.gettoken_str(a)[0]=='/') PRINTHELP()
|
||||
#endif
|
||||
char buf[32];
|
||||
char *t=line.gettoken_str(a++);
|
||||
if (t[0] && CharNext(t)[0] == ':' && CharNext(t)[1] == '\\' && !CharNext(t)[2])
|
||||
|
@ -4053,7 +4071,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
t=buf;
|
||||
}
|
||||
int tf=0;
|
||||
#ifdef _WIN32
|
||||
int v=do_add_file(t, attrib, rec, linecnt,&tf,NULL,which_token == TOK_FILE);
|
||||
#else
|
||||
char *fn = my_convert(t);
|
||||
int v=do_add_file(fn, attrib, rec, linecnt,&tf,NULL,which_token == TOK_FILE);
|
||||
my_convert_free(fn);
|
||||
#endif
|
||||
if (v != PS_OK) return v;
|
||||
if (!tf)
|
||||
{
|
||||
|
@ -4337,7 +4361,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
*p=0;
|
||||
}
|
||||
strcat(nrpath,path);
|
||||
FILE *f=fopen(nrpath, "r");
|
||||
FILE *f=FOPEN(nrpath, "r");
|
||||
if (f) {
|
||||
path=nrpath;
|
||||
fclose(f);
|
||||
|
@ -5283,7 +5307,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
if (line.getnumtokens() == 2)
|
||||
{
|
||||
SCRIPT_MSG("PluginDir: \"%s\"\n",line.gettoken_str(1));
|
||||
#ifdef _WIN32
|
||||
m_plugins.FindCommands(line.gettoken_str(1),display_info?true:false);
|
||||
#else
|
||||
char *converted_path = my_convert(line.gettoken_str(1));
|
||||
m_plugins.FindCommands(converted_path,display_info?true:false);
|
||||
my_convert_free(converted_path);
|
||||
#endif
|
||||
return PS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -5310,7 +5340,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
|
||||
// DLL name on the user machine
|
||||
char tempDLL[NSIS_MAX_STRLEN];
|
||||
wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\'));
|
||||
char *dllName = strrchr(dllPath,PLATFORM_PATH_SEPARATOR_C);
|
||||
if (dllName && *dllName == PLATFORM_PATH_SEPARATOR_C)
|
||||
dllName++;
|
||||
wsprintf(tempDLL, "$PLUGINSDIR%c%s", PATH_SEPARATOR_C, dllName);
|
||||
|
||||
// Add the DLL to the installer
|
||||
if (data_handle == -1)
|
||||
|
@ -5491,11 +5524,11 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
strcpy(dir,lgss);
|
||||
{
|
||||
char *s=dir+strlen(dir);
|
||||
while (s > dir && *s != PATH_SEPARATOR_C) s=CharPrev(dir,s);
|
||||
while (s > dir && *s != PLATFORM_PATH_SEPARATOR_C) s=CharPrev(dir,s);
|
||||
if (s == dir)
|
||||
{
|
||||
if (*s == PATH_SEPARATOR_C)
|
||||
sprintf(dir,"%c.",PATH_SEPARATOR_C);
|
||||
if (*s == PLATFORM_PATH_SEPARATOR_C)
|
||||
sprintf(dir,"%c.",PLATFORM_PATH_SEPARATOR_C);
|
||||
else
|
||||
strcpy(dir,".");
|
||||
}
|
||||
|
@ -5512,14 +5545,14 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
if ((d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
{
|
||||
#else
|
||||
glob(lgss, GLOB_NOSORT, NULL, &globbuf);
|
||||
GLOB(lgss, GLOB_NOSORT, NULL, &globbuf);
|
||||
{
|
||||
for (unsigned int i = 0; i < globbuf.gl_pathc; i++)
|
||||
{
|
||||
struct stat s;
|
||||
if (!stat(globbuf.gl_pathv[i], &s) && S_ISREG(s.st_mode))
|
||||
{
|
||||
char *filename = strrchr(globbuf.gl_pathv[i], PATH_SEPARATOR_C);
|
||||
char *filename = strrchr(globbuf.gl_pathv[i], PLATFORM_PATH_SEPARATOR_C);
|
||||
if (filename)
|
||||
filename++;
|
||||
else
|
||||
|
@ -5532,7 +5565,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
#ifdef _WIN32
|
||||
HANDLE hFile;
|
||||
|
||||
sprintf(newfn,"%s%s%s",dir,dir[0]?PATH_SEPARATOR_STR:"",d.cFileName);
|
||||
sprintf(newfn,"%s%s%s",dir,dir[0]?PLATFORM_PATH_SEPARATOR_STR:"",d.cFileName);
|
||||
hFile = CreateFile(
|
||||
newfn,
|
||||
GENERIC_READ,
|
||||
|
@ -5559,10 +5592,10 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
#else
|
||||
int fd;
|
||||
|
||||
sprintf(newfn,"%s%s%s",dir,dir[0]?PATH_SEPARATOR_STR:"",filename);
|
||||
sprintf(newfn,"%s%s%s",dir,dir[0]?PLATFORM_PATH_SEPARATOR_STR:"",filename);
|
||||
len = (DWORD) s.st_size;
|
||||
|
||||
fd = open(newfn, O_RDONLY);
|
||||
fd = OPEN(newfn, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
globfree(&globbuf);
|
||||
|
@ -5792,7 +5825,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
if (a==INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
a=GetFileAttributes(dir);
|
||||
sprintf(newfn,"%s%s*.*",dir,dir[0]?PATH_SEPARATOR_STR:"");
|
||||
sprintf(newfn,"%s%s*.*",dir,dir[0]?PLATFORM_PATH_SEPARATOR_STR:"");
|
||||
}
|
||||
#else
|
||||
int a;
|
||||
|
@ -5800,7 +5833,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
if (stat(lgss, &st))
|
||||
{
|
||||
stat(dir, &st);
|
||||
sprintf(newfn,"%s%s*",dir,dir[0]?PATH_SEPARATOR_STR:"");
|
||||
sprintf(newfn,"%s%s*",dir,dir[0]?PLATFORM_PATH_SEPARATOR_STR:"");
|
||||
}
|
||||
#endif
|
||||
else
|
||||
|
@ -5828,14 +5861,14 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
#else
|
||||
if (S_ISDIR(st.st_mode))
|
||||
{
|
||||
if (!glob(newfn, GLOB_NOSORT, NULL, &globbuf))
|
||||
if (!GLOB(newfn, GLOB_NOSORT, NULL, &globbuf))
|
||||
{
|
||||
for (unsigned int i = 0; i < globbuf.gl_pathc; i++)
|
||||
{
|
||||
struct stat s;
|
||||
if (!stat(globbuf.gl_pathv[i], &s) && S_ISDIR(s.st_mode))
|
||||
{
|
||||
char *dirname = strrchr(globbuf.gl_pathv[i], PATH_SEPARATOR_C);
|
||||
char *dirname = strrchr(globbuf.gl_pathv[i], PLATFORM_PATH_SEPARATOR_C);
|
||||
if (dirname)
|
||||
dirname++;
|
||||
else
|
||||
|
@ -5876,12 +5909,12 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
|
||||
char spec[1024];
|
||||
#ifdef _WIN32
|
||||
wsprintf(spec,"%s%s%s",dir,dir[0]?PATH_SEPARATOR_STR:"",d.cFileName);
|
||||
wsprintf(spec,"%s%s%s",dir,dir[0]?PLATFORM_PATH_SEPARATOR_STR:"",d.cFileName);
|
||||
#else
|
||||
wsprintf(spec,"%s%s%s",dir,dir[0]?PATH_SEPARATOR_STR:"",dirname);
|
||||
wsprintf(spec,"%s%s%s",dir,dir[0]?PLATFORM_PATH_SEPARATOR_STR:"",dirname);
|
||||
#endif
|
||||
SCRIPT_MSG("%sFile: Descending to: \"%s\"\n",generatecode?"":"Reserve",spec);
|
||||
strcat(spec,PATH_SEPARATOR_STR);
|
||||
strcat(spec,PLATFORM_PATH_SEPARATOR_STR);
|
||||
strcat(spec,fspec);
|
||||
if (generatecode)
|
||||
{
|
||||
|
@ -5914,7 +5947,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
|
|||
FindClose(htemp);
|
||||
#else
|
||||
glob_t globbuf2;
|
||||
glob(spec, GLOB_NOSORT, NULL, &globbuf2);
|
||||
GLOB(spec, GLOB_NOSORT, NULL, &globbuf2);
|
||||
if (globbuf2.gl_pathc)
|
||||
{
|
||||
#endif
|
||||
|
|
|
@ -2,11 +2,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include "exedata.h"
|
||||
#include "exehead/fileform.h"
|
||||
#include "util.h"
|
||||
#include "strlist.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
int g_dopause=0;
|
||||
extern int g_display_errors;
|
||||
extern FILE *g_output;
|
||||
|
@ -28,7 +33,7 @@ void dopause(void)
|
|||
// Returns -3 if the size doesn't match
|
||||
// Returns -4 if the bpp doesn't match
|
||||
int update_bitmap(CResourceEditor* re, WORD id, char* filename, int width/*=0*/, int height/*=0*/, int maxbpp/*=0*/) {
|
||||
FILE *f = fopen(filename, "rb");
|
||||
FILE *f = FOPEN(filename, "rb");
|
||||
if (!f) return -1;
|
||||
|
||||
if (fgetc(f) != 'B' || fgetc(f) != 'M') {
|
||||
|
@ -128,7 +133,7 @@ typedef struct {
|
|||
// -1 - Bad icon file
|
||||
int replace_icon(CResourceEditor* re, WORD wIconId, char* filename)
|
||||
{
|
||||
FILE* f = fopen(filename, "rb");
|
||||
FILE* f = FOPEN(filename, "rb");
|
||||
if (!f) return -1;
|
||||
|
||||
IconGroupHeader igh;
|
||||
|
@ -204,7 +209,7 @@ unsigned char* generate_uninstall_icon_data(char* filename)
|
|||
{
|
||||
int i;
|
||||
|
||||
FILE* f = fopen(filename, "rb");
|
||||
FILE* f = FOPEN(filename, "rb");
|
||||
if (!f) return 0;
|
||||
|
||||
IconGroupHeader igh;
|
||||
|
@ -379,7 +384,7 @@ char *CharPrev(const char *s, const char *p) {
|
|||
char *CharNext(const char *s) {
|
||||
int l = 0;
|
||||
if (s && *s)
|
||||
l = max(1, mblen(s, strlen(s)));
|
||||
l = max(1, mblen(s, MB_CUR_MAX));
|
||||
return (char *) s + l;
|
||||
}
|
||||
|
||||
|
@ -416,7 +421,76 @@ void my_free_realpath(char *path, char *buffer)
|
|||
#endif
|
||||
}
|
||||
|
||||
#define MY_ERROR_MSG(x) {if (g_display_errors) {fprintf(g_output,"%s", x);}}
|
||||
|
||||
char *my_convert(const char *path)
|
||||
{
|
||||
char *converted_path = strdup(path);
|
||||
size_t len = strlen(path);
|
||||
|
||||
if(!converted_path)
|
||||
{
|
||||
MY_ERROR_MSG("Error: could not allocate memory in my_convert()\n");
|
||||
return (char*) path; /* dirty */
|
||||
}
|
||||
|
||||
/* Replace drive letter X: by /X */
|
||||
if(len >= 2)
|
||||
{
|
||||
if (path[1] == ':')
|
||||
{
|
||||
converted_path[0] = '/';
|
||||
converted_path[1] = (char) tolower((int) path[0]);
|
||||
}
|
||||
}
|
||||
|
||||
char *p = converted_path;
|
||||
|
||||
do
|
||||
{
|
||||
if (*p == '\\')
|
||||
{
|
||||
*p = '/';
|
||||
}
|
||||
p = CharNext(p);
|
||||
}
|
||||
while (*p);
|
||||
|
||||
return converted_path;
|
||||
}
|
||||
|
||||
void my_convert_free(char *converted_path)
|
||||
{
|
||||
free(converted_path);
|
||||
}
|
||||
|
||||
int my_open(const char *pathname, int flags)
|
||||
{
|
||||
char *converted_pathname = my_convert(pathname);
|
||||
|
||||
int result = open(converted_pathname, flags);
|
||||
my_convert_free(converted_pathname);
|
||||
return result;
|
||||
}
|
||||
|
||||
FILE *my_fopen(const char *path, const char *mode)
|
||||
{
|
||||
char *converted_path = my_convert(path);
|
||||
|
||||
FILE *result = fopen(converted_path, mode);
|
||||
my_convert_free(converted_path);
|
||||
return result;
|
||||
}
|
||||
|
||||
int my_glob(const char *pattern, int flags,
|
||||
int errfunc(const char * epath, int eerrno), glob_t *pglob)
|
||||
{
|
||||
char *converted_pattern = my_convert(pattern);
|
||||
|
||||
int result = glob(converted_pattern, flags, errfunc, pglob);
|
||||
my_convert_free(converted_pattern);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
void *operator new(size_t size) {
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#ifndef _WIN32
|
||||
# include <iconv.h>
|
||||
# include <stdio.h>
|
||||
# include <glob.h>
|
||||
#endif
|
||||
#include "ResourceEditor.h"
|
||||
|
||||
|
@ -44,6 +46,23 @@ inline size_t __iconv_adaptor
|
|||
{
|
||||
return iconv_func (cd, (T)inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
}
|
||||
|
||||
char *my_convert(const char *path);
|
||||
void my_convert_free(char *converted_path);
|
||||
int my_open(const char *pathname, int flags);
|
||||
FILE *my_fopen(const char *path, const char *mode);
|
||||
int my_glob(const char *pattern, int flags,
|
||||
int errfunc(const char * epath, int eerrno), glob_t *pglob);
|
||||
|
||||
#define FOPEN(a, b) my_fopen(a, b)
|
||||
#define GLOB(a, b, c, d) my_glob(a, b, c, d)
|
||||
#define OPEN(a, b) my_open(a, b)
|
||||
|
||||
#else
|
||||
|
||||
#define FOPEN(a, b) fopen(a, b)
|
||||
#define GLOB(a, b, c, d) glob(a, b, c, d)
|
||||
#define OPEN(a, b) open(a, b)
|
||||
#endif
|
||||
|
||||
#endif //_UTIL_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue