+/* static */
+wxString wxFileName::CreateTempFileName(const wxString& prefix)
+{
+ return wxCreateTempImpl(prefix, WXFILEARGS(NULL, NULL));
+}
+
+#endif // wxUSE_FILE || wxUSE_FFILE
+
+
+#if wxUSE_FILE
+
+wxString wxCreateTempFileName(const wxString& prefix,
+ wxFile *fileTemp,
+ bool *deleteOnClose)
+{
+ return wxCreateTempImpl(prefix, WXFILEARGS(fileTemp, NULL), deleteOnClose);
+}
+
+bool wxCreateTempFile(const wxString& prefix,
+ wxFile *fileTemp,
+ wxString *name)
+{
+ return wxCreateTempImpl(prefix, WXFILEARGS(fileTemp, NULL), name);
+}
+
+void wxFileName::AssignTempFileName(const wxString& prefix, wxFile *fileTemp)
+{
+ wxAssignTempImpl(this, prefix, WXFILEARGS(fileTemp, NULL));
+}
+
+/* static */
+wxString
+wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
+{
+ return wxCreateTempFileName(prefix, fileTemp);
+}
+
+#endif // wxUSE_FILE
+
+
+#if wxUSE_FFILE
+
+wxString wxCreateTempFileName(const wxString& prefix,
+ wxFFile *fileTemp,
+ bool *deleteOnClose)
+{
+ return wxCreateTempImpl(prefix, WXFILEARGS(NULL, fileTemp), deleteOnClose);
+}
+
+bool wxCreateTempFile(const wxString& prefix,
+ wxFFile *fileTemp,
+ wxString *name)
+{
+ return wxCreateTempImpl(prefix, WXFILEARGS(NULL, fileTemp), name);
+
+}
+
+void wxFileName::AssignTempFileName(const wxString& prefix, wxFFile *fileTemp)
+{
+ wxAssignTempImpl(this, prefix, WXFILEARGS(NULL, fileTemp));
+}
+
+/* static */
+wxString
+wxFileName::CreateTempFileName(const wxString& prefix, wxFFile *fileTemp)
+{
+ return wxCreateTempFileName(prefix, fileTemp);
+}
+
+#endif // wxUSE_FFILE
+
+
+// ----------------------------------------------------------------------------
+// directory operations
+// ----------------------------------------------------------------------------
+
+// helper of GetTempDir(): check if the given directory exists and return it if
+// it does or an empty string otherwise
+namespace
+{
+
+wxString CheckIfDirExists(const wxString& dir)
+{
+ return wxFileName::DirExists(dir) ? dir : wxString();
+}
+
+} // anonymous namespace
+
+wxString wxFileName::GetTempDir()
+{
+ // first try getting it from environment: this allows overriding the values
+ // used by default if the user wants to create temporary files in another
+ // directory
+ wxString dir = CheckIfDirExists(wxGetenv("TMPDIR"));
+ if ( dir.empty() )
+ {
+ dir = CheckIfDirExists(wxGetenv("TMP"));
+ if ( dir.empty() )
+ dir = CheckIfDirExists(wxGetenv("TEMP"));
+ }
+
+ // if no environment variables are set, use the system default
+ if ( dir.empty() )
+ {
+#if defined(__WXWINCE__)
+ dir = CheckIfDirExists(wxT("\\temp"));
+#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
+ if ( !::GetTempPath(MAX_PATH, wxStringBuffer(dir, MAX_PATH + 1)) )
+ {
+ wxLogLastError(_T("GetTempPath"));
+ }
+#elif defined(__WXMAC__) && wxOSX_USE_CARBON
+ dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
+#endif // systems with native way
+ }
+
+ // fall back to hard coded value
+ if ( dir.empty() )
+ {
+#ifdef __UNIX_LIKE__
+ dir = CheckIfDirExists("/tmp");
+ if ( dir.empty() )
+#endif // __UNIX_LIKE__
+ dir = ".";
+ }
+
+ return dir;
+}
+
+bool wxFileName::Mkdir( int perm, int flags )
+{
+ return wxFileName::Mkdir(GetPath(), perm, flags);
+}
+
+bool wxFileName::Mkdir( const wxString& dir, int perm, int flags )
+{
+ if ( flags & wxPATH_MKDIR_FULL )
+ {
+ // split the path in components
+ wxFileName filename;
+ filename.AssignDir(dir);
+
+ wxString currPath;
+ if ( filename.HasVolume())
+ {
+ currPath << wxGetVolumeString(filename.GetVolume(), wxPATH_NATIVE);
+ }
+
+ wxArrayString dirs = filename.GetDirs();
+ size_t count = dirs.GetCount();
+ for ( size_t i = 0; i < count; i++ )
+ {
+ if ( i > 0 || filename.IsAbsolute() )
+ currPath += wxFILE_SEP_PATH;
+ currPath += dirs[i];
+
+ if (!DirExists(currPath))
+ {
+ if (!wxMkdir(currPath, perm))
+ {
+ // no need to try creating further directories
+ return false;
+ }
+ }
+ }
+
+ return true;
+
+ }
+
+ return ::wxMkdir( dir, perm );
+}
+
+bool wxFileName::Rmdir()
+{
+ return wxFileName::Rmdir( GetPath() );
+}
+
+bool wxFileName::Rmdir( const wxString &dir )