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 )/*{{{*/ ...@@ -108,11 +108,13 @@ static wxString GetGerberExtension( int layer )/*{{{*/
} }
}/*}}}*/ }/*}}}*/
/** Complete a plot filename: forces the output directory, add a suffix to the name /* Complete a plot filename: forces the output directory,
and sets the extension if specified */ * add a suffix to the name and sets the specified extension
static void BuildPlotFileName( wxFileName *aFilename, /*{{{*/ * the suffix is usually the layer name
*/
static void BuildPlotFileName( wxFileName *aFilename,
const wxString& aOutputDir, const wxString& aOutputDir,
wxString aSuffix, const wxString& aSuffix,
const wxString& aExtension ) const wxString& aExtension )
{ {
aFilename->SetPath( aOutputDir ); aFilename->SetPath( aOutputDir );
...@@ -121,17 +123,21 @@ static void BuildPlotFileName( wxFileName *aFilename, /*{{{*/ ...@@ -121,17 +123,21 @@ static void BuildPlotFileName( wxFileName *aFilename, /*{{{*/
aFilename->SetExt( aExtension ); aFilename->SetExt( aExtension );
/* remove leading and trailing spaces if any from the suffix, if /* remove leading and trailing spaces if any from the suffix, if
something survives add it to the name; also the suffix can contain something survives add it to the name;
an extension: if that's the case, apply it */ also the suffix can contain some not allowed chars in filename (/ \ .),
aSuffix.Trim( true ); aSuffix.Trim( false ); so change them to underscore
*/
wxFileName suffix_fn( aSuffix ); wxString suffix = aSuffix;
suffix.Trim( true );
if( suffix_fn.HasName() ) suffix.Trim( false );
aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix_fn.GetName() );
if( suffix_fn.HasExt() ) suffix.Replace( wxT("."), wxT("_") );
aFilename->SetExt( suffix_fn.GetExt() ); 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 */ /** Fix the output directory pathname to absolute and ensure it exists */
static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/ 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