No more Windows error message when using IfFileExists on a removable drive with no media inserted - now applies to all internal file_exists calls.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2976 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
eccles 2003-09-28 12:14:10 +00:00
parent a72067fab9
commit 7d99fd6700
2 changed files with 9 additions and 11 deletions

View file

@ -263,12 +263,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
case EW_IFFILEEXISTS: case EW_IFFILEEXISTS:
{ {
char *buf0=GetStringFromParm(0x00); char *buf0=GetStringFromParm(0x00);
WIN32_FIND_DATA *fd; if (file_exists(buf0))
// Avoid a "There is no disk in the drive" error box on empty removable drives
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
fd = file_exists(buf0);
SetErrorMode(0);
if (fd)
{ {
log_printf3("IfFileExists: file \"%s\" exists, jumping %d",buf0,parm1); log_printf3("IfFileExists: file \"%s\" exists, jumping %d",buf0,parm1);
return parm1; return parm1;

View file

@ -140,7 +140,7 @@ void NSISCALL trimslashtoend(char *buf)
break; break;
p = CharPrev(buf, p); p = CharPrev(buf, p);
} while (p > buf); } while (p > buf);
*p = 0; *p = 0;
} }
@ -375,8 +375,8 @@ int NSISCALL myatoi(char *s)
char m=10; // base of 0 char m=10; // base of 0
char t='9'; // cap top of numbers at 9 char t='9'; // cap top of numbers at 9
if (*s == '-') if (*s == '-')
{ {
s++; //skip over - s++; //skip over -
sign=-1; // sign flip sign=-1; // sign flip
} }
@ -571,7 +571,7 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
#else #else
if (nVarIdx == 255) if (nVarIdx == 255)
{ {
*out++ = *in++; *out++ = *in++;
} }
else if (nVarIdx == VAR_CODES_START) else if (nVarIdx == VAR_CODES_START)
@ -637,7 +637,7 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
case 35: // SYSDIR case 35: // SYSDIR
GetSystemDirectory(out, NSIS_MAX_STRLEN); GetSystemDirectory(out, NSIS_MAX_STRLEN);
break; break;
case 36: // HWNDPARENT case 36: // HWNDPARENT
myitoa(out, (unsigned int)g_hwnd); myitoa(out, (unsigned int)g_hwnd);
break; break;
@ -740,7 +740,10 @@ WIN32_FIND_DATA * NSISCALL file_exists(char *buf)
{ {
HANDLE h; HANDLE h;
static WIN32_FIND_DATA fd; static WIN32_FIND_DATA fd;
// Avoid a "There is no disk in the drive" error box on empty removable drives
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
h = FindFirstFile(buf,&fd); h = FindFirstFile(buf,&fd);
SetErrorMode(0);
if (h != INVALID_HANDLE_VALUE) if (h != INVALID_HANDLE_VALUE)
{ {
FindClose(h); FindClose(h);