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
This commit is contained in:
jean-pierre charras 2017-01-23 11:32:58 +01:00
parent 6a1b068dd2
commit d7ed3ede72
1 changed files with 17 additions and 2 deletions

View File

@ -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: