← Back to team overview

kicad-developers team mailing list archive

[PATCH] Eeschema support to remote libraries with sftp

 

Hello,

This patch is a correction to Eeschema to use properly sftp to open
remote libraries.

Best regards,
From 5888f08e096a7a0236129eb01cdccab4b93c2b63 Mon Sep 17 00:00:00 2001
From: "Patrick J.P" <patrick.pereira@xxxxxxxxx>
Date: Wed, 11 May 2016 15:20:09 -0300
Subject: [PATCH] Eeschema support to remote libraries access

Allow remote libraries access when using sftp in Eeschema.

Signed-off-by: Patrick J.P <patrick.pereira@xxxxxxxxx>
---
 common/search_stack.cpp    | 16 +++++++++++++---
 eeschema/class_library.cpp | 20 +++++++++++---------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/common/search_stack.cpp b/common/search_stack.cpp
index 9982f41..cc7eb02 100644
--- a/common/search_stack.cpp
+++ b/common/search_stack.cpp
@@ -38,11 +38,23 @@ int SEARCH_STACK::Split( wxArrayString* aResult, const wxString aPathString )
 {
     wxStringTokenizer   tokenizer( aPathString, PATH_SEPS, wxTOKEN_STRTOK );
 
+    wxString temp;
+    temp.Clear();
     while( tokenizer.HasMoreTokens() )
     {
         wxString path = tokenizer.GetNextToken();
+        if( !temp.IsEmpty() )
+        {
+            path=temp+":"+path;
+            temp.Clear();
+        }
 
-        aResult->Add( path );
+        if( !path.Contains("/gvfs/sftp") )
+            aResult->Add( path );
+        else
+        {
+            temp = path;
+        }
     }
 
     return aResult->GetCount();
@@ -118,7 +130,6 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
 {
     bool            isCS = wxFileName::IsCaseSensitive();
     wxArrayString   paths;
-
     Split( &paths, aPaths );
 
     // appending all of them, on large or negative aIndex
@@ -127,7 +138,6 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
         for( unsigned i=0; i<paths.GetCount();  ++i )
         {
             wxString path = paths[i];
-
             if( wxFileName::IsDirReadable( path )
                 && Index( path, isCS ) == wxNOT_FOUND )
             {
diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp
index f051319..137d5ad 100644
--- a/eeschema/class_library.cpp
+++ b/eeschema/class_library.cpp
@@ -823,7 +823,6 @@ PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR, bo
 PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer )
 {
     PART_LIB* lib;
-
 #if 1
     wxFileName fn = aFileName;
     // Don't reload the library if it is already loaded.
@@ -1101,6 +1100,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR, boost::ba
     wxFileName      fn;
     wxString        filename;
     wxString        libs_not_found;
+    wxString        libs_not_found_error;
     SEARCH_STACK*   lib_search = aProject->SchSearchS();
 
 #if defined(DEBUG) && 1
@@ -1132,11 +1132,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR, boost::ba
             filename = lib_search->FindValidPath( fn.GetFullPath() );
 
             if( !filename )
-            {
-                libs_not_found += fn.GetName();
-                libs_not_found += wxT( '\n' );
-                continue;
-            }
+                filename = aProject->GetProjectPath() + fn.GetFullPath();
         }
         else
         {
@@ -1149,14 +1145,16 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR, boost::ba
         }
         catch( const IO_ERROR& ioe )
         {
-            wxString msg = wxString::Format( _(
-                    "Part library '%s' failed to load. Error:\n"
+            libs_not_found_error += wxString::Format( _(
+                    "Part library '%s' : '%s' failed to load. Error:\n"
                     "%s" ),
                     GetChars( filename ),
+                    GetChars( fn.GetName() ),
                     GetChars( ioe.errorText )
                     );
 
-            THROW_IO_ERROR( msg );
+            libs_not_found += fn.GetName();
+            libs_not_found += wxT( '\n' );
         }
     }
 
@@ -1197,6 +1195,10 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR, boost::ba
     printf( "%s: lib_names:\n", __func__ );
 
     for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
+    {
         printf( " %s\n", TO_UTF8( it->GetName() ) );
+    }
+
+    printf(" %s ", TO_UTF8( libs_not_found_error ) );
 #endif
 }
-- 
2.8.2


Follow ups