Create the import directory if it doesn't exist
Fixes sentry KICAD-6BC
This commit is contained in:
parent
b8bbbcf410
commit
5321c1c481
|
@ -84,7 +84,21 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
|
||||||
importProj.m_TargetProj.SetExt( FILEEXT::ProjectFileExtension );
|
importProj.m_TargetProj.SetExt( FILEEXT::ProjectFileExtension );
|
||||||
importProj.m_TargetProj.MakeAbsolute();
|
importProj.m_TargetProj.MakeAbsolute();
|
||||||
|
|
||||||
// Check if the project directory is empty
|
// Check if the project directory exists and is empty
|
||||||
|
if( !importProj.m_TargetProj.DirExists() )
|
||||||
|
{
|
||||||
|
if( !importProj.m_TargetProj.Mkdir() )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
msg.Printf( _( "Folder '%s' could not be created.\n\n"
|
||||||
|
"Make sure you have write permissions and try again." ),
|
||||||
|
importProj.m_TargetProj.GetPath() );
|
||||||
|
DisplayErrorMessage( this, msg );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
wxDir targetDirTest( targetDir );
|
wxDir targetDirTest( targetDir );
|
||||||
if( targetDirTest.IsOpened() && targetDirTest.HasFiles() )
|
if( targetDirTest.IsOpened() && targetDirTest.HasFiles() )
|
||||||
{
|
{
|
||||||
|
@ -106,7 +120,8 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
|
||||||
msg = _( "Error creating new directory. Please try a different path. The "
|
msg = _( "Error creating new directory. Please try a different path. The "
|
||||||
"project cannot be imported." );
|
"project cannot be imported." );
|
||||||
|
|
||||||
wxMessageDialog dirErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR );
|
wxMessageDialog dirErrorDlg( this, msg, _( "Error" ),
|
||||||
|
wxOK_DEFAULT | wxICON_ERROR );
|
||||||
dirErrorDlg.ShowModal();
|
dirErrorDlg.ShowModal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +129,7 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
|
||||||
}
|
}
|
||||||
|
|
||||||
targetDirTest.Close();
|
targetDirTest.Close();
|
||||||
|
}
|
||||||
|
|
||||||
CreateNewProject( importProj.m_TargetProj.GetFullPath(), false /* Don't create stub files */ );
|
CreateNewProject( importProj.m_TargetProj.GetFullPath(), false /* Don't create stub files */ );
|
||||||
LoadProject( importProj.m_TargetProj );
|
LoadProject( importProj.m_TargetProj );
|
||||||
|
|
Loading…
Reference in New Issue