More robust parsing, so that dosbox -fullscreen A.EXE works
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3934
This commit is contained in:
parent
96fb43a208
commit
cb28976df6
1 changed files with 23 additions and 14 deletions
|
@ -379,38 +379,42 @@ public:
|
|||
bool addexit = control->cmdline->FindExist("-exit",true);
|
||||
|
||||
/* Check for first command being a directory or file */
|
||||
char buffer[CROSS_LEN];
|
||||
char orig[CROSS_LEN];
|
||||
char buffer[CROSS_LEN+1];
|
||||
char orig[CROSS_LEN+1];
|
||||
char cross_filesplit[2] = {CROSS_FILESPLIT , 0};
|
||||
/* Combining -securemode and no parameter leaves you with a lovely Z:\. */
|
||||
if ( !control->cmdline->FindCommand(1,line) ) {
|
||||
if ( secure ) autoexec[12].Install("z:\\config.com -securemode");
|
||||
} else {
|
||||
|
||||
Bitu dummy = 1;
|
||||
bool command_found = false;
|
||||
while (control->cmdline->FindCommand(dummy++,line) && !command_found) {
|
||||
struct stat test;
|
||||
if (line.length() > CROSS_LEN) continue;
|
||||
strcpy(buffer,line.c_str());
|
||||
if (stat(buffer,&test)){
|
||||
getcwd(buffer,CROSS_LEN);
|
||||
if (stat(buffer,&test)) {
|
||||
if (getcwd(buffer,CROSS_LEN) == NULL) continue;
|
||||
if (strlen(buffer) + line.length() + 1 > CROSS_LEN) continue;
|
||||
strcat(buffer,cross_filesplit);
|
||||
strcat(buffer,line.c_str());
|
||||
if (stat(buffer,&test)) goto nomount;
|
||||
if (stat(buffer,&test)) continue;
|
||||
}
|
||||
if (test.st_mode & S_IFDIR) {
|
||||
autoexec[12].Install(std::string("MOUNT C \"") + buffer + "\"");
|
||||
autoexec[13].Install("C:");
|
||||
if(secure) autoexec[14].Install("z:\\config.com -securemode");
|
||||
command_found = true;
|
||||
} else {
|
||||
char* name = strrchr(buffer,CROSS_FILESPLIT);
|
||||
if (!name) { //Only a filename
|
||||
line = buffer;
|
||||
getcwd(buffer,CROSS_LEN);
|
||||
if (getcwd(buffer,CROSS_LEN) == NULL) continue;
|
||||
if (strlen(buffer) + line.length() + 1 > CROSS_LEN) continue;
|
||||
strcat(buffer,cross_filesplit);
|
||||
strcat(buffer,line.c_str());
|
||||
if(stat(buffer,&test)) goto nomount;
|
||||
if(stat(buffer,&test)) continue;
|
||||
name = strrchr(buffer,CROSS_FILESPLIT);
|
||||
if(!name) goto nomount;
|
||||
if(!name) continue;
|
||||
}
|
||||
*name++ = 0;
|
||||
if (access(buffer,F_OK)) goto nomount;
|
||||
if (access(buffer,F_OK)) continue;
|
||||
autoexec[12].Install(std::string("MOUNT C \"") + buffer + "\"");
|
||||
autoexec[13].Install("C:");
|
||||
/* Save the non-modified filename (so boot and imgmount can use it (long filenames, case sensivitive)) */
|
||||
|
@ -437,9 +441,14 @@ public:
|
|||
autoexec[15].Install(name);
|
||||
if(addexit) autoexec[16].Install("exit");
|
||||
}
|
||||
command_found = true;
|
||||
}
|
||||
}
|
||||
nomount:
|
||||
|
||||
/* Combining -securemode, noautoexec and no parameters leaves you with a lovely Z:\. */
|
||||
if ( !command_found ) {
|
||||
if ( secure ) autoexec[12].Install("z:\\config.com -securemode");
|
||||
}
|
||||
VFILE_Register("AUTOEXEC.BAT",(Bit8u *)autoexec_data,(Bit32u)strlen(autoexec_data));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue