Save: Fix issues with adding an extension if missing
- The code should search for the last '.', not the first. - Case-insensitively compare the extensions.
This commit is contained in:
parent
9318e4de94
commit
4c6338888d
1 changed files with 7 additions and 2 deletions
|
@ -82,8 +82,13 @@ filedialog_output_params show_filedialog(wxWindow* parent, const std::string& ti
|
|||
if(saving && p.types[findex].primaryext != "") {
|
||||
//Append extension if needed.
|
||||
std::string ext = p.types[findex].primaryext;
|
||||
size_t dpos = filename.find_first_of(".");
|
||||
if(dpos > filename.length() || filename.substr(dpos + 1) != ext)
|
||||
size_t dpos = filename.find_last_of(".");
|
||||
std::string extension;
|
||||
if(dpos < filename.length()) {
|
||||
extension = filename.substr(dpos + 1);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||
}
|
||||
if(extension != ext)
|
||||
filename = filename + "." + ext;
|
||||
}
|
||||
filedialog_output_params r;
|
||||
|
|
Loading…
Add table
Reference in a new issue