In C, checking for existence of file with name matching a pattern
问题 I've seen a few methods for checking the existence of a file in C. However, everything I've seen works for a specific file name. I would like to check for any file that matches a particular pattern. For instance, maybe the pattern is "lockfile*" and "lockfileA", "lockfile.txt", or "lockfile.abc" would register in the check. The way I am doing this currently is to open the directory with opendir() then cycle through readdir() and try to match the pattern with name of each file returned. It