diff --git a/pcbnew/python/scripting/pcb_scripting_tool.cpp b/pcbnew/python/scripting/pcb_scripting_tool.cpp index 990b7f81cd..e50cce2ee8 100644 --- a/pcbnew/python/scripting/pcb_scripting_tool.cpp +++ b/pcbnew/python/scripting/pcb_scripting_tool.cpp @@ -26,6 +26,8 @@ #include #include +#include +#include #include @@ -156,7 +158,38 @@ pcbnew.LoadPlugins( sys_path, user_path, third_party_path ) void SCRIPTING_TOOL::ShowPluginFolder() { wxString pluginpath( SCRIPTING::PyPluginsPath( SCRIPTING::PATH_TYPE::USER ) ); - LaunchExternal( pluginpath ); + + if( wxFileName::DirExists( pluginpath ) ) + { + if( !LaunchExternal( pluginpath ) ) + { + wxMessageBox( wxString::Format( _( "Unable to open plugin directory '%s'." ), pluginpath ), + _( "Plugin Directory" ), wxOK | wxICON_ERROR ); + } + + return; + } + + wxString msg = wxString::Format( _( "The plugin directory '%s' does not exist. Create it?" ), pluginpath ); + + wxMessageDialog dlg( nullptr, msg, _( "Plugin Directory" ), wxYES_NO | wxICON_QUESTION ); + + if( dlg.ShowModal() == wxID_YES ) + { + if( wxFileName::Mkdir( pluginpath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) ) + { + if( !LaunchExternal( pluginpath ) ) + { + wxMessageBox( wxString::Format( _( "Unable to open plugin directory '%s'." ), pluginpath ), + _( "Plugin Directory" ), wxOK | wxICON_ERROR ); + } + } + else + { + wxMessageBox( wxString::Format( _( "Unable to create plugin directory '%s'." ), pluginpath ), + _( "Plugin Directory" ), wxOK | wxICON_ERROR ); + } + } }