rowspan=4*((w*(channels(pf)*8)+31)/32);
if(multi_image)
{
- String
- newfilename(filename),
- ext(find(filename.begin(),filename.end(),'.'),filename.end());
- newfilename.erase(find(newfilename.begin(),newfilename.end(),'.'),newfilename.end());
-
- newfilename+=etl::strprintf("%04d",imagecount)+ext;
+ String newfilename(filename_sans_extension(filename) +
+ etl::strprintf("%04d",imagecount) +
+ filename_extension(filename));
file=fopen(newfilename.c_str(),"wb");
if(callback)callback->task(newfilename+_(" (animated)"));
}
bool
imagemagick_trgt::set_rend_desc(RendDesc *given_desc)
{
- String ext(find(filename.begin(),filename.end(),'.')+1,filename.end());
- if(ext=="xpm")
+ if(filename_extension(filename) == ".xpm")
pf=PF_RGB;
else
pf=PF_RGB|PF_A;
}
else if(multi_image)
{
- String
- newfilename(filename),
- ext(find(filename.begin(),filename.end(),'.'),filename.end());
- newfilename.erase(find(newfilename.begin(),newfilename.end(),'.'),newfilename.end());
-
- newfilename+=etl::strprintf("%04d",imagecount)+ext;
+ String newfilename(filename_sans_extension(filename) +
+ etl::strprintf("%04d",imagecount) +
+ filename_extension(filename));
file=fopen(newfilename.c_str(),"wb");
if(callback)callback->task(newfilename);
}
delete exr_file;
if(multi_image)
{
- String
- newfilename(filename),
- ext(find(filename.begin(),filename.end(),'.'),filename.end());
- newfilename.erase(find(newfilename.begin(),newfilename.end(),'.'),newfilename.end());
-
- newfilename+=etl::strprintf("%04d",imagecount)+ext;
- frame_name=newfilename;
- if(cb)cb->task(newfilename);
+ frame_name = (filename_sans_extension(filename) +
+ etl::strprintf("%04d",imagecount) +
+ filename_extension(filename));
+ if(cb)cb->task(frame_name);
}
else
{
}
else if(multi_image)
{
- String
- newfilename(filename),
- ext(find(filename.begin(),filename.end(),'.'),filename.end());
- newfilename.erase(find(newfilename.begin(),newfilename.end(),'.'),newfilename.end());
-
- newfilename+=etl::strprintf("%04d",imagecount)+ext;
+ String newfilename(filename_sans_extension(filename) +
+ etl::strprintf("%04d",imagecount) +
+ filename_extension(filename));
file=fopen(newfilename.c_str(),"wb");
if(callback)callback->task(newfilename);
}
}
else if(multi_image)
{
- String
- newfilename(filename),
- ext(find(filename.begin(),filename.end(),'.'),filename.end());
- newfilename.erase(find(newfilename.begin(),newfilename.end(),'.'),newfilename.end());
-
- newfilename+=etl::strprintf("%04d",imagecount)+ext;
+ String newfilename(filename_sans_extension(filename) +
+ etl::strprintf("%04d",imagecount) +
+ filename_extension(filename));
file=SmartFILE(fopen(newfilename.c_str(),"wb"));
if(callback)callback->task(newfilename);
}
return (*__open_importers)[filename];
}
- if(find(filename.begin(),filename.end(),'.')==filename.end())
+ if(filename_extension(filename) == "")
{
synfig::error(_("Importer::open(): Couldn't find extension"));
return 0;
}
- String ext=string(filename.begin()+filename.find_last_of('.')+1,filename.end());
+ String ext(filename_extension(filename));
+ if (ext.size()) ext = ext.substr(1); // skip initial '.'
std::transform(ext.begin(),ext.end(),ext.begin(),&::tolower);
synfig::String tmp_filename(filename+".TMP");
- if (String(filename.begin() + filename.find_last_of('.')+1, filename.end()) == "sifz")
+ if (filename_extension(filename) == ".sifz")
xmlSetCompressMode(9);
else
xmlSetCompressMode(0);
// Strip the "file://" part from the filename
filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
- String ext;
- try{ext=(String(filename.begin()+filename.find_last_of('.')+1,filename.end()));}catch(...){continue;}
+ String ext(filename_extension(filename));
+ if (ext.size()) ext = ext.substr(1); // skip initial '.'
// If this is a SIF file, then we need to do things slightly differently
if(ext=="sketch")
if(find(filename.begin(),filename.end(),'*')!=filename.end())
continue;
- std::string base = basename(filename);
- if(find(base.begin(),base.end(),'.')==base.end())
+ if (filename_extension(filename) == "")
filename+=".sifz";
try
{
- String ext(String(filename.begin()+filename.find_last_of('.')+1,filename.end()));
- if(ext!="sif" && ext!="sifz" && !App::dialog_yes_no(_("Unknown extension"),
+ String ext(filename_extension(filename));
+ if(ext!=".sif" && ext!=".sifz" && !App::dialog_yes_no(_("Unknown extension"),
_("You have given the file name an extension\nwhich I do not recognise. Are you sure this is what you want?")))
- {
continue;
- }
}
catch(...)
{
void
RenderSettings::set_entry_filename()
{
- String filename(canvas_interface_->get_canvas()->get_file_name());
-
- // if the basename of the filename has an extension, remove it
- String base = basename(filename);
- if(find(base.begin(),base.end(),'.')!=base.end())
- filename = String(filename.begin(), filename.begin()+filename.find_last_of('.'));
+ String filename(filename_sans_extension(canvas_interface_->get_canvas()->get_file_name()));
// if this isn't the root canvas, append (<canvasname>) to the filename
etl::handle<synfig::Canvas> canvas = canvas_interface_->get_canvas();
{
try
{
- String ext=String(find(filename.begin(),filename.end(),'.')+1,filename.end());
+ String ext(filename_extension(filename));
+ if (ext.size()) ext=ext.substr(1); // skip initial '.'
if(Target::ext_book().count(ext))
target_name=Target::ext_book()[ext];
else
synfig::info("Attempting to import "+filename);
-
- if(find(filename.begin(),filename.end(),'.')==filename.end())
+ if (filename_extension(filename) == "")
{
get_ui_interface()->error("Filename must have an extension!");
return false;
}
- String ext(String(filename.begin()+filename.find_last_of('.')+1,filename.end()));
+ String ext(filename_extension(filename));
+ if (ext.size()) ext = ext.substr(1); // skip initial '.'
std::transform(ext.begin(),ext.end(),ext.begin(),&::tolower);
// If this is a SIF file, then we need to do things slightly differently