- 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:
-
- // 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);
- }