From d7ed3ede72096eacc17def398d366ddab2b17b4a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 23 Jan 2017 11:32:58 +0100 Subject: [PATCH] Ensure paths and filenames are always stored with '/' as separator in fp_lib_table, like in other kicad files. Ensure also paths and filenames read from a fp_lib_table always use '/' as separator (works fine on Windows) Fixes: lp:1658534 https://bugs.launchpad.net/kicad/+bug/1658534 --- common/lib_table_base.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index 73ebf6cfc0..0e0a0da3a9 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -83,10 +83,15 @@ const wxString LIB_TABLE_ROW::GetFullURI( bool aSubstituted ) const void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR, boost::interprocess::lock_exception ) { + // In Kicad, we save path and file names using the Unix notation (separator = '/') + // So ensure separator is always '/' is saved URI string + wxString uri = GetFullURI(); + uri.Replace( '\\', '/' ); + out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n", out->Quotew( GetNickName() ).c_str(), out->Quotew( GetType() ).c_str(), - out->Quotew( GetFullURI() ).c_str(), + out->Quotew( uri ).c_str(), out->Quotew( GetOptions() ).c_str(), out->Quotew( GetDescr() ).c_str() ); @@ -143,7 +148,17 @@ void LIB_TABLE_ROW::Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, LIB_TABLE_LEX in->Duplicate( tok ); sawUri = true; in->NeedSYMBOLorNUMBER(); - aRow->SetFullURI( in->FromUTF8() ); + // Saved path and file names use the Unix notation (separator = '/') + // However old files, and files edited by hands can use the woindows + // separator. Force the unix notation + // (It works on windows, and moreover, wxFileName and wxDir takes care to that + // on windows) + // moreover, URLs use the '/' as separator + { + wxString uri = in->FromUTF8(); + uri.Replace( '\\', '/' ); + aRow->SetFullURI( uri ); + } break; case T_type: