- if ( !of.nFileExtension || (of.nFileExtension && fileNameBuffer[ of.nFileExtension-1] != wxT('.')) )
- { // user has typed an filename
- // without an extension:
+ 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');
+ }