(v13) next_file return next matching file
This page applies to Harlequin v13.1r0 and later; and to Harlequin Core but not Harlequin MultiRIP
int32 next_file (
DEVICELIST *dev,
void **handle,
uint8 *pattern, FILEENTRY *entry );
typedef struct {
int32 namelength; uint8 *name;
} FILEENTRY;
In this structure, handle
is a pointer to the value returned from the call to start_file_list
. It should be used to identify the current point in this enumeration, and can be modified by next_file
if necessary.
pattern
is a pointer to the same template passed to start_file_list
for this enumeration. entry
is a pointer to a FILEENTRY
structure. If there is another match for the pattern, a pointer to the filename should be stored in the name
field (there is no need to NUL-terminate it, but remember that it cannot be a string on the C stack), and namelength
set to the length of that filename. FileNameMatch
should then be returned. If the filename is too long, FileNameRangeCheck
should be returned.
If there are no more matches, FileNameNoMatch
should be returned. If an error occurred while looking for a match, FileNameError
should be returned. The last_error
routine will then be called to determine the error.
The names FileNameMatch
, FileNameRangeCheck
, FileNameNoMatch
, FileNameError
are defined in swdevice.h
.
Note that if the underlying file system supports directories and the permissions on one or more directories do not allow the filenames in those directories to be enumerated this should not be treated as an error. The routine should just ignore those directories and continue the search for matches.
There are two routines implemented by the Harlequin Core that can be used in the implementation of next_file
. These are:
SwPatternMatch ( uint8 *pattern, uint8 *string)
SwLengthPatternMatch ( uint8 *pattern, int32 plen, uint8 * string, int32 slen)
The SwPatternMatch
routine returns non-zero if the zero-terminated string matches the NULterminated pattern, or zero if the string does not match the pattern.
SwLengthPatternMatch i
s similar but the pattern and string are given by start address and length, and may not be NUL-terminated.