=== modified file 'src/file.cpp' --- src/file.cpp 2011-03-14 19:50:25 +0000 +++ src/file.cpp 2011-04-24 07:52:23 +0000 @@ -830,6 +830,15 @@ else g_warning( "Error converting save filename to UTF-8." ); + + Inkscape::Extension::Output *omod; + omod = dynamic_cast(selectionType); + Glib::ustring save_extension = (std::string)omod->get_extension(); + + if (!hasEnding(fileName, save_extension.c_str() )) + fileName += save_extension.c_str(); + + // FIXME: does the argument !is_copy really convey the correct meaning here? success = file_save(parentWindow, doc, fileName, selectionType, TRUE, !is_copy, save_method); @@ -847,6 +856,18 @@ return false; } +/** + * Check if a string ends with another string. + */ +bool hasEnding (Glib::ustring const &fullString, Glib::ustring const &ending) +{ + if (fullString.length() > ending.length()) { + return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending)); + } else { + return false; + } +} + /** * Save a document, displaying a SaveAs dialog if necessary. === modified file 'src/file.h' --- src/file.h 2009-09-27 21:36:48 +0000 +++ src/file.h 2011-04-24 06:07:38 +0000 @@ -115,6 +115,10 @@ /* Do the saveas dialog with a document as the parameter */ bool sp_file_save_dialog (Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extension::FileSaveMethod save_method); +/** + * Check if a string ends with another string. + */ +bool hasEnding (Glib::ustring const &fullString, Glib::ustring const &ending); /*###################### ## I M P O R T