Added a wildfildcmp function for correct dos like wildcard matching of files.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@367
This commit is contained in:
parent
4bff708fa3
commit
1b242dcbda
1 changed files with 52 additions and 0 deletions
|
@ -19,6 +19,58 @@
|
|||
#include "dosbox.h"
|
||||
#include "dos_system.h"
|
||||
#include "drives.h"
|
||||
#include "support.h"
|
||||
|
||||
bool WildFileCmp(const char * file, const char * wild)
|
||||
{
|
||||
char file_name[9];
|
||||
char file_ext[4];
|
||||
char wild_name[9];
|
||||
char wild_ext[4];
|
||||
char * find_ext;
|
||||
Bitu r;
|
||||
|
||||
strcpy(file_name," ");
|
||||
strcpy(file_ext," ");
|
||||
strcpy(wild_name," ");
|
||||
strcpy(wild_ext," ");
|
||||
|
||||
find_ext=strchr(file,'.');
|
||||
if (find_ext) {
|
||||
Bitu size=find_ext-file;if (size>8) size=8;
|
||||
memcpy(file_name,file,size);
|
||||
find_ext++;
|
||||
memcpy(file_ext,find_ext,(strlen(find_ext)>3) ? 3 : strlen(find_ext));
|
||||
} else {
|
||||
memcpy(file_name,file,(strlen(file) > 8) ? 8 : strlen(file));
|
||||
}
|
||||
upcase(file_name);upcase(file_ext);
|
||||
find_ext=strchr(wild,'.');
|
||||
if (find_ext) {
|
||||
Bitu size=find_ext-wild;if (size>8) size=8;
|
||||
memcpy(wild_name,wild,size);
|
||||
find_ext++;
|
||||
memcpy(wild_ext,find_ext,(strlen(find_ext)>3) ? 3 : strlen(find_ext));
|
||||
} else {
|
||||
memcpy(wild_name,wild,(strlen(wild) > 8) ? 8 : strlen(wild));
|
||||
}
|
||||
upcase(wild_name);upcase(wild_ext);
|
||||
/* Names are right do some checking */
|
||||
r=0;
|
||||
while (r<8) {
|
||||
if (wild_name[r]=='*') goto checkext;
|
||||
if (wild_name[r]!='?' && wild_name[r]!=file_name[r]) return false;
|
||||
r++;
|
||||
}
|
||||
checkext:
|
||||
while (r<3) {
|
||||
if (wild_ext[r]=='*') return true;
|
||||
if (wild_ext[r]!='?' && wild_ext[r]!=file_ext[r]) return false;
|
||||
r++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DOS_Drive::DOS_Drive() {
|
||||
|
|
Loading…
Add table
Reference in a new issue