+ FIND_DATA fd = ::FindFirstFile(spec.t_str(), finddata);
+
+ // As in FindNext() above, we need to check that the file name we found
+ // really matches our filter and look for the next match if it doesn't.
+ if ( IsFindDataOk(fd) && !CheckFoundMatch(finddata, filter) )
+ {
+ if ( !FindNext(fd, filter, finddata) )
+ {
+ // As we return the invalid handle from here to indicate that we
+ // didn't find anything, close the one we initially received
+ // ourselves.
+ FreeFindData(fd);
+
+ return INVALID_HANDLE_VALUE;
+ }
+ }
+
+ return fd;