1
0
Fork 0

Which now check's .com .exe .bat in that order.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@259
This commit is contained in:
Sjoerd van der Berg 2002-09-04 22:00:35 +00:00
parent 6470f16447
commit c5d481d1fd

View file

@ -193,32 +193,25 @@ static char which_ret[DOS_PATHLENGTH];
char * DOS_Shell::Which(char * name) {
/* Parse through the Path to find the correct entry */
// if (which_result) free(which_result);
/* Check for extension */
/* Check if name is already ok but just misses an extension */
char * ext=strrchr(name,'.');
if (ext) if (strlen(ext)>4) ext=0;
if (ext) {
if (DOS_FileExists(name)) return name;
} else {
/* try to find .exe .com .bat */
strcpy(which_ret,name);
strcat(which_ret,bat_ext);
if (DOS_FileExists(which_ret)) return which_ret;
/* try to find .com .exe .bat */
strcpy(which_ret,name);
strcat(which_ret,com_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,name);
strcat(which_ret,exe_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,name);
strcat(which_ret,bat_ext);
if (DOS_FileExists(which_ret)) return which_ret;
}
/* No Path in filename look through %path% */
static char path[DOS_PATHLENGTH];
char * pathenv=GetEnvStr("PATH");
if (!pathenv) return 0;
@ -238,17 +231,16 @@ char * DOS_Shell::Which(char * name) {
if (ext) {
if (DOS_FileExists(which_ret)) return which_ret;
} else {
strcpy(which_ret,path);
strcat(which_ret,bat_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,path);
strcat(which_ret,com_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,path);
strcat(which_ret,exe_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,path);
strcat(which_ret,bat_ext);
if (DOS_FileExists(which_ret)) return which_ret;
}
path_write=path;
if (*pathenv) pathenv++;
}