+ wxSplitPath( zFileNameBuffer
+ ,&m_path
+ ,&m_fileName
+ ,&sExt
+ );
+ if (zFileNameBuffer[nIdx] == wxT('.') || sExt.empty())
+ {
+ zFileNameBuffer[nIdx] = wxT('\0');
+
+ //
+ // 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 < (int)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_path = wxString(zFileNameBuffer) + pzExtension;
+ }
+ }
+ }
+ else
+ {
+ m_path = (wxChar*)vFileDlg.szFullFile;
+ }
+ m_fileName = wxFileNameFromPath((const wxChar*)vFileDlg.szFullFile);
+ m_dir = wxPathOnly((const wxChar*)vFileDlg.szFullFile);
+
+ //
+ // === Simulating the wxFD_OVERWRITE_PROMPT >>============================
+ //
+ if ((m_windowStyle & wxFD_OVERWRITE_PROMPT) &&
+ (m_windowStyle & wxFD_SAVE) &&
+ (wxFileExists(m_path.c_str())))
+ {
+ wxString sMessageText;
+
+ sMessageText.Printf( _("File '%s' already exists.\nDo you want to replace it?")
+ ,m_path.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