- // Find path only so we can concatenate
- // found file onto path
- wxString p2(wxFileSpec);
- char *p = wxPathOnly(WXSTRINGCAST p2);
- if (p && (strlen(p) > 0))
- strcpy(wxBuffer, p);
- else
- wxBuffer[0] = 0;
-
- try_again:
-
-#ifdef __WIN32__
- if (wxFileStrucHandle == INVALID_HANDLE_VALUE)
- return NULL;
-
- bool success = (FindNextFile(wxFileStrucHandle, &wxFileStruc) != 0);
- if (!success) {
- FindClose(wxFileStrucHandle);
- wxFileStrucHandle = INVALID_HANDLE_VALUE;
- return NULL;
- }
-
- bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
-
- if (isdir && !(wxFindFileFlags & wxDIR))
- goto try_again;
- else if (!isdir && wxFindFileFlags && !(wxFindFileFlags & wxFILE))
- goto try_again;
-
- if (wxBuffer[0] != 0)
- strcat(wxBuffer, "\\");
- strcat(wxBuffer, wxFileStruc.cFileName);
- return wxBuffer;
-#else
-
-#ifdef __BORLANDC__
- if (findnext(&wxFileStruc) == 0)
-#else
- if (_dos_findnext(&wxFileStruc) == 0)
-#endif
- {
- /* MATTHEW: [5] Check directory flag */
- char attrib;
-
-#ifdef __BORLANDC__
- attrib = wxFileStruc.ff_attrib;
-#else
- attrib = wxFileStruc.attrib;
-#endif
-
- if (attrib & _A_SUBDIR) {
- if (!(wxFindFileFlags & wxDIR))
- goto try_again;
- } else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE))
- goto try_again;
-
-
- if (wxBuffer[0] != 0)
- strcat(wxBuffer, "\\");
-#ifdef __BORLANDC__
- strcat(wxBuffer, wxFileStruc.ff_name);
-#else
- strcat(wxBuffer, wxFileStruc.name);
-#endif
- return wxBuffer;
- }
- else
- return NULL;
-#endif
-}