|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sfldir.h"
Bool
file_matches (
const char *filename,
const char *pattern)
Returns TRUE if the filename matches the pattern. The pattern is a character string that can contain these 'wildcard' characters:
{
char
*pattern_ptr, /* Points to pattern */
*filename_ptr; /* Points to filename */
filename_ptr = (char *) filename; /* Start comparing file name */
pattern_ptr = (char *) pattern; /* Start comparing file name */
FOREVER
{
/* If we came to the end of the pattern and the filename, we have */
/* successful match. */
if (*pattern_ptr == '\0' && *filename_ptr == '\0')
return (TRUE); /* Have a match */
/* Otherwise, end of either is a failed match */
if (*pattern_ptr == '\0' || *filename_ptr == '\0')
return (FALSE); /* Match failed */
/* If the pattern character is '?', then we matched a char */
if (*pattern_ptr == '?'
#if (defined (NAMEFOLD))
|| toupper (*pattern_ptr) == toupper (*filename_ptr))
#else
|| *pattern_ptr == *filename_ptr)
#endif
{
pattern_ptr++;
filename_ptr++;
}
else
/* If we have a '*', match as much of the filename as we can */
if (*pattern_ptr == '*')
{
pattern_ptr++; /* Try to match following char */
while (*filename_ptr && *filename_ptr != *pattern_ptr)
filename_ptr++;
}
else
return (FALSE); /* Match failed */
}
}
| | << | < | > | >> |
|