+ //
+ // User has typed a filename without an extension:
+ //
+ // A filename can end in a "." here ("abc."), this means it
+ // does not have an extension. Because later on a "." with
+ // the default extension is appended we remove the "." if
+ // filename ends with one (We don't want files called
+ // "abc..ext")
+ //
+ pzExtension = sFilterBuffer.c_str();
+
+ for( int i = 0; i < sFilterBuffer.length(); i++ )
+ {
+ //
+ // Get extension
+ //
+ pzExtension = wxStrrchr(pzExtension, wxT('.'));
+ if ( pzExtension &&
+ !wxStrrchr(pzExtension, wxT('*')) &&
+ !wxStrrchr(pzExtension, wxT('?')) &&
+ pzExtension[1] &&
+ pzExtension[1] != wxT(' ')
+ ) // != "blabla. "
+ {
+ //
+ // Now concat extension to the fileName:
+ //
+ m_sPath = wxString(zFileNameBuffer) + pzExtension;
+ }
+ }
+ }
+ else
+ {
+ m_sPath = vFileDlg.szFullFile;
+ }
+ m_sFileName = wxFileNameFromPath(vFileDlg.szFullFile);
+ m_sDir = wxPathOnly(vFileDlg.szFullFile);
+
+ //
+ // === Simulating the wxOVERWRITE_PROMPT >>============================
+ //
+ if ((m_lDialogStyle & wxOVERWRITE_PROMPT) &&
+ (m_lDialogStyle & wxSAVE) &&
+ (wxFileExists(m_sPath.c_str())))
+ {
+ wxString sMessageText;
+
+ sMessageText.Printf( _("File '%s' already exists.\nDo you want to replace it?")
+ ,m_sPath.c_str()
+ );
+ if (wxMessageBox( sMessageText
+ ,wxT("Save File As")
+ ,wxYES_NO | wxICON_EXCLAMATION
+ ) != wxYES)
+ {
+ return wxID_CANCEL;
+ }
+ }
+ }
+ return wxID_OK;
+ }
+ return wxID_CANCEL;
+} // end of wxFileDialog::ShowModal