Hello, I`ve found a way to match the directory entries without the empty lines and non dir strings:
Code:
while ( fgets(buff, 512, fp) ) {
#ifdef __gnu_linux__
if ( (fnmres = fnmatch("/*", buff, 0)) == 0)
printf("[DBG][fnmatch()]: %s %d\n", buff, fnmres);
#endif
However it also matches files like /home/user/log.txt, but for now it fits for my desires.
Originally Posted by
jimblumberg
The first thing I suggest is that you check the return value from the function, to make clear your intention.
Code:
if ( fnmatch("?/*.?/", buffer, 0) == 0)
Remember this function returns zero if it finds a match, some non-zero value otherwise.
Next if that doesn't help, have you checked your wildcard string works at the command line?
Jim