- wxString result;
-#ifdef __VMS
- wxChar *specvms = NULL;
-#endif
-
-#if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
- if (gs_dirStream)
- closedir(gs_dirStream); // edz 941103: better housekeping
-
- gs_findFlags = flags;
-
- gs_strFileSpec = spec;
-
- // Find path only so we can concatenate
- // found file onto path
- wxString path(wxPathOnly(gs_strFileSpec));
-
- // special case: path is really "/"
- if ( !path && gs_strFileSpec[0u] == wxT('/') )
-#ifdef __VMS
- {
- wxStrcpy( specvms , wxT( "[000000]" ) );
- gs_strFileSpec = specvms;
- wxString path_vms(wxPathOnly(gs_strFileSpec));
- path = path_vms;
- }
-#else
- path = wxT('/');
-#endif
- // path is empty => Local directory
- if ( !path )
-#ifdef __VMS
- {
- wxStrcpy( specvms , wxT( "[]" ) );
- gs_strFileSpec = specvms;
- wxString path_vms1(wxPathOnly(gs_strFileSpec));
- path = path_vms1;
- }
-#else
- path = wxT('.');
-#endif
-
- gs_dirStream = opendir(path.fn_str());
- if ( !gs_dirStream )
- {
- wxLogSysError(_("Can not enumerate files in directory '%s'"),
- path.c_str());
- }
- else
- {
- result = wxFindNextFile();
- }
-#endif // !VMS6.x or earlier
-
- return result;
-}
-
-wxString wxFindNextFile()
-{
- wxString result;
-
-#if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
- wxCHECK_MSG( gs_dirStream, result, wxT("must call wxFindFirstFile first") );
-
- // Find path only so we can concatenate
- // found file onto path
- wxString path(wxPathOnly(gs_strFileSpec));
- wxString name(wxFileNameFromPath(gs_strFileSpec));
-
- /* MATTHEW: special case: path is really "/" */
- if ( !path && gs_strFileSpec[0u] == wxT('/'))
- path = wxT('/');
-
- // Do the reading
- struct dirent *nextDir;
- for ( nextDir = readdir(gs_dirStream);
- nextDir != NULL;
- nextDir = readdir(gs_dirStream) )
+ gs_dirPath = wxPathOnly(spec);
+ if ( gs_dirPath.IsEmpty() )
+ gs_dirPath = wxT(".");
+ if ( gs_dirPath.Last() != wxFILE_SEP_PATH )
+ gs_dirPath << wxFILE_SEP_PATH;
+
+ if (gs_dir)
+ delete gs_dir;
+ gs_dir = new wxDir(gs_dirPath);
+
+ if ( !gs_dir->IsOpened() )