-bool wxRemoveFile(const wxString& file)
-{
-#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
- int flag = remove(wxFNSTRINGCAST file.fn_str());
-#elif defined( __WXMAC__ )
- wxStrcpy( gwxMacFileName , file ) ;
- wxUnix2MacFilename( gwxMacFileName ) ;
- int flag = unlink(gwxMacFileName);
+ wxFile fileOut;
+ if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) )
+ return false;
+
+ // copy contents of file1 to file2
+ char buf[4096];
+ size_t count;
+ for ( ;; )
+ {
+ count = fileIn.Read(buf, WXSIZEOF(buf));
+ if ( fileIn.Error() )
+ return false;
+
+ // end of file?
+ if ( !count )
+ break;
+
+ if ( fileOut.Write(buf, count) < count )
+ return false;
+ }
+
+ // we can expect fileIn to be closed successfully, but we should ensure
+ // that fileOut was closed as some write errors (disk full) might not be
+ // detected before doing this
+ if ( !fileIn.Close() || !fileOut.Close() )
+ return false;
+
+#if !defined(__VISAGECPP__) && !defined(__WXMAC__) || defined(__UNIX__)
+ // no chmod in VA. Should be some permission API for HPFS386 partitions
+ // however
+ if ( chmod(OS_FILENAME(file2), fbuf.st_mode) != 0 )
+ {
+ wxLogSysError(_("Impossible to set permissions for the file '%s'"),
+ file2.c_str());
+ return false;
+ }
+#endif // OS/2 || Mac
+
+#else // !Win32 && ! wxUSE_FILE
+
+ // impossible to simulate with wxWidgets API
+ wxUnusedVar(file1);
+ wxUnusedVar(file2);
+ wxUnusedVar(overwrite);
+ return false;
+
+#endif // __WXMSW__ && __WIN32__
+
+ return true;
+}
+
+bool
+wxRenameFile (const wxString& file1, const wxString& file2)
+{
+#if !defined(__WXWINCE__) && !defined(__WXPALMOS__)
+ // Normal system call
+ if ( wxRename (file1, file2) == 0 )
+ return true;
+#endif
+
+ // Try to copy
+ if (wxCopyFile(file1, file2)) {
+ wxRemoveFile(file1);
+ return true;
+ }
+ // Give up
+ return false;
+}
+
+bool wxRemoveFile(const wxString& file)
+{
+#if defined(__VISUALC__) \
+ || defined(__BORLANDC__) \
+ || defined(__WATCOMC__) \
+ || defined(__DMC__) \
+ || defined(__GNUWIN32__) \
+ || (defined(__MWERKS__) && defined(__MSL__))
+ int res = wxRemove(file);
+#elif defined(__WXMAC__)
+ int res = unlink(wxFNCONV(file));
+#elif defined(__WXPALMOS__)
+ int res = 1;
+ // TODO with VFSFileDelete()