Resolve textvars in plot directory.
Fixes https://gitlab.com/kicad/code/kicad/issues/10405
This commit is contained in:
parent
f3a583e490
commit
e5d5ee07f0
|
@ -248,9 +248,20 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile )
|
|||
{
|
||||
m_outputDirectory = m_outputDirectoryName->GetValue();
|
||||
|
||||
// Create output directory if it does not exist (also transform it in
|
||||
// absolute form). Bail if it fails
|
||||
wxString path = ExpandEnvVarSubstitutions( m_outputDirectory, &Prj() );
|
||||
// Create output directory if it does not exist (also transform it in absolute form).
|
||||
// Bail if it fails.
|
||||
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles m_board->GetTitleBlock() *and* m_board->GetProject()
|
||||
return m_board->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_outputDirectory;
|
||||
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
|
||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_board->GetFileName();
|
||||
|
||||
|
|
|
@ -380,9 +380,20 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap )
|
|||
if( choice >= arrayDim( filefmt ) )
|
||||
choice = 1;
|
||||
|
||||
// Create output directory if it does not exist (also transform it in
|
||||
// absolute form). Bail if it fails
|
||||
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
// Create output directory if it does not exist (also transform it in absolute form).
|
||||
// Bail if it fails.
|
||||
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles m_board->GetTitleBlock() *and* m_board->GetProject()
|
||||
return m_board->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_plotOpts.GetOutputDirectory();
|
||||
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
|
||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_board->GetFileName();
|
||||
|
||||
|
|
|
@ -796,12 +796,23 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
|||
return;
|
||||
}
|
||||
|
||||
// Create output directory if it does not exist (also transform it in
|
||||
// absolute form). Bail if it fails
|
||||
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_parent->GetBoard()->GetFileName();
|
||||
REPORTER& reporter = m_messagesPanel->Reporter();
|
||||
// Create output directory if it does not exist (also transform it in absolute form).
|
||||
// Bail if it fails.
|
||||
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles board->GetTitleBlock() *and* board->GetProject()
|
||||
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_plotOpts.GetOutputDirectory();
|
||||
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
|
||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_parent->GetBoard()->GetFileName();
|
||||
REPORTER& reporter = m_messagesPanel->Reporter();
|
||||
|
||||
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
|
||||
{
|
||||
|
|
|
@ -266,9 +266,20 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles()
|
|||
wxString msg;
|
||||
int fullcount = 0;
|
||||
|
||||
// Create output directory if it does not exist. Also transform it in absolute path.
|
||||
// Bail if it fails
|
||||
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
// Create output directory if it does not exist (also transform it in absolute form).
|
||||
// Bail if it fails.
|
||||
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles board->GetTitleBlock() *and* board->GetProject()
|
||||
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_plotOpts.GetOutputDirectory();
|
||||
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
|
||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_parent->GetBoard()->GetFileName();
|
||||
|
||||
|
@ -363,10 +374,20 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
|||
}
|
||||
}
|
||||
|
||||
// Create output directory if it does not exist.
|
||||
// Also transform it in absolute path.
|
||||
// Bail if it fails
|
||||
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
// Create output directory if it does not exist (also transform it in absolute form).
|
||||
// Bail if it fails.
|
||||
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles board->GetTitleBlock() *and* board->GetProject()
|
||||
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_plotOpts.GetOutputDirectory();
|
||||
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
|
||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_parent->GetBoard()->GetFileName();
|
||||
|
||||
|
|
|
@ -437,10 +437,21 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat
|
|||
ClosePlot();
|
||||
|
||||
// Now compute the full filename for the output and start the plot (after ensuring the
|
||||
// output directory is OK)
|
||||
wxString outputDirName = GetPlotOptions().GetOutputDirectory() ;
|
||||
// output directory is OK).
|
||||
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles m_board->GetTitleBlock() *and* m_board->GetProject()
|
||||
return m_board->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString outputDirName = GetPlotOptions().GetOutputDirectory();
|
||||
outputDirName = ExpandTextVars( outputDirName, &textResolver, nullptr, nullptr );
|
||||
outputDirName = ExpandEnvVarSubstitutions( outputDirName, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( outputDirName );
|
||||
wxString boardFilename = m_board->GetFileName();
|
||||
wxString boardFilename = m_board->GetFileName();
|
||||
|
||||
if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue