Commit 4794d377 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix incorrect filenames when plotting layers

parent 3688bae7
......@@ -108,11 +108,13 @@ static wxString GetGerberExtension( int layer )/*{{{*/
}
}/*}}}*/
/** Complete a plot filename: forces the output directory, add a suffix to the name
and sets the extension if specified */
static void BuildPlotFileName( wxFileName *aFilename, /*{{{*/
/* Complete a plot filename: forces the output directory,
* add a suffix to the name and sets the specified extension
* the suffix is usually the layer name
*/
static void BuildPlotFileName( wxFileName *aFilename,
const wxString& aOutputDir,
wxString aSuffix,
const wxString& aSuffix,
const wxString& aExtension )
{
aFilename->SetPath( aOutputDir );
......@@ -121,17 +123,21 @@ static void BuildPlotFileName( wxFileName *aFilename, /*{{{*/
aFilename->SetExt( aExtension );
/* remove leading and trailing spaces if any from the suffix, if
something survives add it to the name; also the suffix can contain
an extension: if that's the case, apply it */
aSuffix.Trim( true ); aSuffix.Trim( false );
wxFileName suffix_fn( aSuffix );
if( suffix_fn.HasName() )
aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix_fn.GetName() );
if( suffix_fn.HasExt() )
aFilename->SetExt( suffix_fn.GetExt() );
}/*}}}*/
something survives add it to the name;
also the suffix can contain some not allowed chars in filename (/ \ .),
so change them to underscore
*/
wxString suffix = aSuffix;
suffix.Trim( true );
suffix.Trim( false );
suffix.Replace( wxT("."), wxT("_") );
suffix.Replace( wxT("/"), wxT("_") );
suffix.Replace( wxT("\\"), wxT("_") );
if( !suffix.IsEmpty() )
aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix );
}
/** Fix the output directory pathname to absolute and ensure it exists */
static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment