- for (short suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000)
- {
- wxSprintf (tmp, wxT("/tmp/%s%d.%03x"), WXSTRINGCAST prefix, (int) getpid (), (int) suffix);
- if (!wxFileExists( tmp ))
- {
- // Touch the file to create it (reserve name)
- FILE *fd = fopen (wxFNCONV(tmp), "w");
- if (fd)
- fclose (fd);
- last_temp = suffix;
- if (buf)
- wxStrcpy( buf, tmp);
- else
- buf = copystring( tmp );
- return buf;
- }
- }
- wxLogError( _("wxWindows: error finding temporary file name.\n") );
- if (buf) buf[0] = 0;
- return (wxChar *) NULL;
-#endif
-}
-
-bool wxGetTempFileName(const wxString& prefix, wxString& buf)
-{
- wxChar buf2[512];
- if (wxGetTempFileName(prefix, buf2) != (wxChar*) NULL)
- {
- buf = buf2;
- return TRUE;
- }
- else
- return FALSE;
-}
-
-// Get first file name matching given wild card.
-
-#ifdef __UNIX__
-
-// Get first file name matching given wild card.
-// Flags are reserved for future use.
-
-#if !defined( __VMS__ ) || ( __VMS_VER >= 70000000 )
- static DIR *gs_dirStream = (DIR *) NULL;
- static wxString gs_strFileSpec;
- static int gs_findFlags = 0;
-#endif
-
-wxString wxFindFirstFile(const wxChar *spec, int flags)
-{
- 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());
- }