From d79fff5d9e5977270b124fcd40a1970155e9b11b Mon Sep 17 00:00:00 2001 From: charras Date: Sat, 11 Apr 2009 15:50:31 +0000 Subject: [PATCH] eeschema library cache name changed from .cache.lib to -cache.lib. Needed with the new code using wxFileName --- eeschema/eelibs_read_libraryfiles.cpp | 4 ++-- eeschema/files-io.cpp | 29 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index 7ec01c7402..e1048a162f 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -115,7 +115,7 @@ void LoadLibraries (WinEDA_DrawFrame* frame) frame->PrintMsg( _( "Loading schematic component libraries" ) ); - // Free the unwanted libraries (i.e. not in list) but keep the .cache lib + // Free the unwanted libraries (i.e. not in list) but keep the cache lib LibraryStruct* nextlib, * lib = g_LibraryList; for( ; lib != NULL; lib = nextlib ) @@ -164,7 +164,7 @@ void LoadLibraries (WinEDA_DrawFrame* frame) else msg += _( " error!" ); - frame->PrintMsg( msg ); + frame->PrintMsg( msg ); } // reorder the linked list to match the order filename list: diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index fc6c6b0bc5..8488ac63dc 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -150,10 +150,22 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, return 1; } - // Loading the project library cache + /* Loading the project library cache + * until apr 2009 the lib is named .cache.lib + * and after (due to code change): -cache.lib + * so if the -cache.lib is not foun, the od way will be tried + */ + bool use_oldcachename = false; wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; - fn.SetExt( wxT( "cache.lib" ) ); - + wxString cachename = fn.GetName() + wxT("-cache"); + fn.SetName( cachename ); + fn.SetExt( CompLibFileExtension ); + if( ! fn.FileExists() ) + { + fn = g_RootSheet->m_AssociatedScreen->m_FileName; + fn.SetExt( wxT( "cache.lib" ) ); + use_oldcachename = true; + } if( fn.FileExists() ) { wxLogDebug( wxT( "Load schematic cache library file <%s>" ), @@ -165,6 +177,13 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, { LibCache->m_IsLibCache = TRUE; msg += wxT( " OK" ); + if ( use_oldcachename ) // set the new name + { + fn.SetName(cachename); + fn.SetExt( CompLibFileExtension ); + LibCache->m_Name = fn.GetName(); + LibCache->m_FullFileName = fn.GetFullPath(); + } } else msg += wxT( " ->Error" ); @@ -241,7 +260,9 @@ void WinEDA_SchematicFrame::SaveProject() /* Creation du fichier d'archivage composants en repertoire courant */ fn = g_RootSheet->GetFileName(); - fn.SetExt( wxT( "cache." ) + CompLibFileExtension ); + wxString cachename = fn.GetName() + wxT("-cache"); + fn.SetName( cachename ); + fn.SetExt( CompLibFileExtension ); LibArchive( this, fn.GetFullPath() ); }