- m_filterIndex = (int)of.nFilterIndex - 1;
-
- if ( !of.nFileExtension ||
- (of.nFileExtension && fileNameBuffer[of.nFileExtension] == 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")
- int idx = wxStrlen(fileNameBuffer) - 1;
- if ( fileNameBuffer[idx] == wxT('.') )
- {
- fileNameBuffer[idx] = wxT('\0');
- }
-
- int maxFilter = (int)(of.nFilterIndex*2L-1L);
- extension = filterBuffer;
-
- for( int i = 0; i < maxFilter; i++ ) { // get extension
- extension = extension + wxStrlen( extension ) +1;
- }
-
- extension = wxStrrchr( extension, wxT('.') );
- if ( extension // != "blabla"
- && !wxStrrchr( extension, wxT('*') ) // != "blabla.*"
- && !wxStrrchr( extension, wxT('?') ) // != "blabla.?"
- && extension[1] // != "blabla."
- && extension[1] != wxT(' ') ) // != "blabla. "
- {
- // now concat extension to the fileName:
- m_fileName = wxString(fileNameBuffer) + extension;
-
- int len = wxStrlen( fileNameBuffer );
- wxStrncpy( fileNameBuffer + len, extension, wxMAXPATH - len );
- fileNameBuffer[ wxMAXPATH -1 ] = wxT('\0');
- }
- }
-
- m_path = fileNameBuffer;
- m_fileName = wxFileNameFromPath(fileNameBuffer);
- m_fileNames.Add(m_fileName);
- m_dir = wxPathOnly(fileNameBuffer);
- }
- //=== Simulating the wxOVERWRITE_PROMPT >>============================
- //should we also test for file save style ??
- if ( (m_dialogStyle & wxOVERWRITE_PROMPT) &&
- ::wxFileExists( fileNameBuffer ) )
- {
- wxString messageText;
- messageText.Printf(_("File '%s' already exists.\nDo you want to replace it?"), fileNameBuffer);
- if ( wxMessageBox(messageText, wxT("Save File As"), wxYES_NO | wxICON_EXCLAMATION ) != wxYES )
- {
- success = FALSE;
- }
- }