Listing specific files in a directory
The GNU site has some example code for listing directory files, found here. According to the documentation, the scandir function allows the user to specify a function with which directory entires will be compared and selects files if they return something other than zero when tested with this function. In the code example they have written a function that simply returns 1, making sure that all files are returned.
I am interested in finding files with particular names and following some suggestions elsewhere on this forum I was able to get some code working using regex.h to match filenames. What is not clear is how to modify the "one" function to compare directory entries with a regular expression. What should be passed to the function and how would one match the relevant parts of the dirent struct against the regex?
Thanks for any suggestions.