From 3a33a5b506c96895d262b48c7f55ca75137806b1 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 21 Sep 2025 19:52:11 -0700 Subject: [PATCH] Ensure table directories are created Use static routines to create needed directories before copying files Fixes https://gitlab.com/kicad/code/kicad/-/issues/18937 Fixes https://gitlab.com/kicad/code/kicad/-/issues/18938 (cherry picked from commit 3eeb2a1ad7c129e5c068341daf13953da77bf168) --- common/design_block_lib_table.cpp | 3 ++- .../dialogs/dialog_global_design_block_lib_table_config.cpp | 4 ++-- common/fp_lib_table.cpp | 3 ++- eeschema/dialogs/dialog_global_sym_lib_table_config.cpp | 3 ++- eeschema/symbol_lib_table.cpp | 3 ++- pcbnew/dialogs/dialog_global_fp_lib_table_config.cpp | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/design_block_lib_table.cpp b/common/design_block_lib_table.cpp index 43c60083bf..4c978fa0b8 100644 --- a/common/design_block_lib_table.cpp +++ b/common/design_block_lib_table.cpp @@ -631,7 +631,8 @@ bool DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE& aTable ) { tableExists = false; - if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) + if( !wxFileName::DirExists( fn.GetPath() ) + && !wxFileName::Mkdir( fn.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) { THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ), fn.GetPath() ) ); diff --git a/common/dialogs/dialog_global_design_block_lib_table_config.cpp b/common/dialogs/dialog_global_design_block_lib_table_config.cpp index 8b787cc99d..8af698c0f4 100644 --- a/common/dialogs/dialog_global_design_block_lib_table_config.cpp +++ b/common/dialogs/dialog_global_design_block_lib_table_config.cpp @@ -108,8 +108,8 @@ bool DIALOG_GLOBAL_DESIGN_BLOCK_LIB_TABLE_CONFIG::TransferDataFromWindow() // Create the config path if it doesn't already exist. wxFileName designBlockTableFileName = DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName(); - if( !designBlockTableFileName.DirExists() - && !designBlockTableFileName.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) + if( !wxFileName::DirExists( designBlockTableFileName.GetPath() ) + && !wxFileName::Mkdir( designBlockTableFileName.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) { DisplayError( this, wxString::Format( _( "Cannot create global library table '%s'." ), designBlockTableFileName.GetPath() ) ); diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 4491b8548b..3c63e4aa30 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -628,7 +628,8 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) { tableExists = false; - if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) + if( !wxFileName::DirExists( fn.GetPath() ) + && !wxFileName::Mkdir( fn.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) { THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ), fn.GetPath() ) ); diff --git a/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp b/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp index 7afeda8d9d..777055818d 100644 --- a/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp +++ b/eeschema/dialogs/dialog_global_sym_lib_table_config.cpp @@ -103,7 +103,8 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow() // Create the config path if it doesn't already exist. wxFileName symTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName(); - if( !symTableFileName.DirExists() && !symTableFileName.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) + if( !wxFileName::DirExists( symTableFileName.GetPath() ) + && !wxFileName::Mkdir( symTableFileName.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) { DisplayError( this, wxString::Format( _( "Cannot create global library table '%s'." ), symTableFileName.GetPath() ) ); diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp index 9728bb7251..3bac6b6756 100644 --- a/eeschema/symbol_lib_table.cpp +++ b/eeschema/symbol_lib_table.cpp @@ -629,7 +629,8 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable ) { tableExists = false; - if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) + if( !wxFileName::DirExists( fn.GetPath() ) + && !wxFileName::Mkdir( fn.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) { THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ), fn.GetPath() ) ); diff --git a/pcbnew/dialogs/dialog_global_fp_lib_table_config.cpp b/pcbnew/dialogs/dialog_global_fp_lib_table_config.cpp index e25a6325af..fe9a509011 100644 --- a/pcbnew/dialogs/dialog_global_fp_lib_table_config.cpp +++ b/pcbnew/dialogs/dialog_global_fp_lib_table_config.cpp @@ -104,7 +104,8 @@ bool DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow() // Create the config path if it doesn't already exist. wxFileName fpTableFileName = FP_LIB_TABLE::GetGlobalTableFileName(); - if( !fpTableFileName.DirExists() && !fpTableFileName.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) + if( !wxFileName::DirExists( fpTableFileName.GetPath() ) + && !wxFileName::Mkdir( fpTableFileName.GetPath(), 0x777, wxPATH_MKDIR_FULL ) ) { DisplayError( this, wxString::Format( _( "Cannot create library table path '%s'." ), fpTableFileName.GetPath() ) );