Use the ETL functions to find filename extensions and filenames without extensions...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 29 Nov 2007 19:30:43 +0000 (19:30 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 29 Nov 2007 19:30:43 +0000 (19:30 +0000)
git-svn-id: http://svn.voria.com/code@1170 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/tool/main.cpp

index 6a20447..4f1618c 100644 (file)
@@ -965,7 +965,8 @@ int main(int argc, char *argv[])
                        if(target_name.empty() && !job_list.front().outfilename.empty())
                        {
                                VERBOSE_OUT(3)<<_("Target name undefined, attempting to figure it out")<<endl;
-                               string ext=job_list.front().outfilename.substr(job_list.front().outfilename.rfind('.')+1);
+                               string ext = filename_extension(job_list.front().outfilename);
+                               if (ext.length()) ext = ext.substr(1);
                                if(Target::ext_book().count(ext))
                                        target_name=Target::ext_book()[ext];
                                else
@@ -985,9 +986,7 @@ int main(int argc, char *argv[])
                        // given input filename. (ie: change the extension)
                        if(job_list.front().outfilename.empty())
                        {
-                               job_list.front().outfilename=job_list.front().filename;
-                               job_list.front().outfilename.erase(find(job_list.front().outfilename.begin(),job_list.front().outfilename.end(),'.'),job_list.front().outfilename.end());
-                               job_list.front().outfilename+='.';
+                               job_list.front().outfilename = filename_sans_extension(job_list.front().filename) + '.';
                                if(Target::book().count(target_name))
                                        job_list.front().outfilename+=Target::book()[target_name].second;
                                else