- wxString dir(m_dir);
- if ( m_dir.Last() != _T('\\') )
- dir += _T('\\');
-
- m_fileNames.Sort();
- m_path = dir + m_fileName;
- }
- else
- {
- const wxChar* extension = NULL;
-
- //=== Adding the correct extension >>=================================
-
- m_filterIndex = (int)of.nFilterIndex - 1;
-
- if ( !of.nFileExtension ||
- (of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) )
- {
- // User has typed a filename without an extension:
-
- 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');
- }
- }