Skip to content
Snippets Groups Projects
Commit 7c187f35 authored by deuce's avatar deuce
Browse files

Add wildmatch(fname, spec, path) function which matches the string

fname against the filespec spec, not allowing * to match the path delimiter
if path is TRUE.
parent c9e452c8
No related branches found
No related tags found
No related merge requests found
......@@ -859,3 +859,44 @@ BOOL DLLCALL isfullpath(const char* filename)
#endif
);
}
/****************************************************************************/
/* Matches file name against filespec */
/* Optionally not allowing * to match PATH_DELIM (for paths) */
/****************************************************************************/
BOOL DLLCALL wildmatch(const char *fname, const char *spec, BOOL path)
{
char *specp;
char *fnamep;
specp=(char *)spec;
fnamep=(char *)fname;
for(;;specp++, fnamep++) {
switch(*specp) {
case '?':
if(!(*fnamep))
return(FALSE);
break;
case 0:
if(!*fnamep)
return(TRUE);
break;
case '*':
specp++;
for(;*fnamep!=*specp && *fnamep;fnamep++) {
if(path && IS_PATH_DELIM(*fnamep))
return(FALSE);
}
default:
if(*specp != *fnamep)
return(FALSE);
}
if(!(*specp && *fnamep))
break;
}
while(*specp=='*')
specp++;
if(*specp==*fnamep)
return(TRUE);
return(FALSE);
}
......@@ -230,6 +230,8 @@ DLLEXPORT int DLLCALL getfattr(const char* filename);
DLLEXPORT ulong DLLCALL getfreediskspace(const char* path, ulong unit);
DLLEXPORT ulong DLLCALL delfiles(char *inpath, char *spec);
DLLEXPORT char* DLLCALL backslash(char* path);
DLLEXPORT BOOL DLLCALL wildmatch(const char *fname, const char *spec, BOOL path);
#if defined(__unix__)
DLLEXPORT void DLLCALL _splitpath(const char *path, char *drive, char *dir,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment