eschema, pcbnew and cvpcb did not find libraries when they were in the default library path, but in a subdirectory
This commit is contained in:
parent
b9049c506f
commit
9c3d5bd96d
|
@ -4,6 +4,16 @@ Started 2007-June-11
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2007-Nov-032 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||
================================================================================
|
||||
+all:
|
||||
solved: eeschema, pcbnew and cvpcb did not find libraries when they were
|
||||
in the default library path, but in a subdirectory
|
||||
(this is because the default path was not added to the name if the name had
|
||||
already a path)
|
||||
|
||||
|
||||
|
||||
2007-Nov-02 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
|
||||
================================================================================
|
||||
+ pcbnew
|
||||
|
|
|
@ -85,17 +85,18 @@ wxString MakeReducedFileName( const wxString& fullfilename,
|
|||
const wxString& default_ext )
|
||||
/***************************************************************************/
|
||||
|
||||
/* Calcule le nom "reduit" d'un fichier d'apres les chaines
|
||||
* fullfilename = nom complet
|
||||
* default_path = prefixe (chemin) par defaut
|
||||
* default_ext = extension par defaut
|
||||
/** Function MakeReducedFileName
|
||||
* Calculate the "reduced" filename from
|
||||
* @param fullfilename = full filename
|
||||
* @param default_path = default path
|
||||
* @param default_ext = default extension
|
||||
*
|
||||
* retourne le nom reduit, c'est a dire:
|
||||
* sans le chemin si le chemin est default_path
|
||||
* avec ./ si si le chemin est le chemin courant
|
||||
* sans l'extension si l'extension est default_ext
|
||||
* @return the "reduced" filename, i.e.:
|
||||
* without path if it is default_path
|
||||
* wiht ./ if the path is the current path
|
||||
* without extension if extension is default_ext
|
||||
*
|
||||
* Renvoie un chemin en notation unix ('/' en separateur de repertoire)
|
||||
* the new flename is in unix like notation ('/' as path separator)
|
||||
*/
|
||||
{
|
||||
wxString reduced_filename = fullfilename;
|
||||
|
@ -111,18 +112,19 @@ wxString MakeReducedFileName( const wxString& fullfilename,
|
|||
path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
// names are case insensitive under windows
|
||||
path.MakeLower();
|
||||
Cwd.MakeLower();
|
||||
ext.MakeLower();
|
||||
#endif
|
||||
|
||||
// Si le fichier est dans chemin par defaut -> suppression du chemin par defaut
|
||||
// if the path is "default_path" -> remove it
|
||||
wxString root_path = path.Left( Cwd.Length() );
|
||||
if( root_path == Cwd )
|
||||
{
|
||||
reduced_filename.Remove( 0, Cwd.Length() );
|
||||
}
|
||||
else // Si fichier dans repertoire courant -> chemin = ./
|
||||
else // if the path is the current path -> change path to ./
|
||||
{
|
||||
Cwd = wxGetCwd() + UNIX_STRING_DIR_SEP;
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -130,14 +132,14 @@ wxString MakeReducedFileName( const wxString& fullfilename,
|
|||
#endif
|
||||
Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||
if( path == Cwd )
|
||||
{ // lib est dans répertoire courant -> Chemin = "./"
|
||||
{ // the path is the current path -> path = "./"
|
||||
reduced_filename.Remove( 0, Cwd.Length() );
|
||||
wxString tmp = wxT( "./" ) + reduced_filename;
|
||||
reduced_filename = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// Suppression extension standard:
|
||||
// remove extension if == default_ext:
|
||||
if( !ext.IsEmpty() && reduced_filename.Contains( ext ) )
|
||||
reduced_filename.Truncate( reduced_filename.Length() - ext.Length() );
|
||||
|
||||
|
@ -150,15 +152,14 @@ wxString MakeFileName( const wxString& dir,
|
|||
const wxString& shortname, const wxString& ext )
|
||||
/***************************************************************************/
|
||||
|
||||
/* Calcule le nom complet d'un fichier d'apres les chaines
|
||||
* dir = prefixe (chemin) (peut etre "")
|
||||
* shortname = nom avec ou sans chemin ou extension
|
||||
* ext = extension (peut etre "")
|
||||
*
|
||||
* si shortname possede deja un chemin ou une extension, elles
|
||||
* ne seront pas modifiees
|
||||
*
|
||||
* retourne la chaine calculee
|
||||
/** Function MakeFileName
|
||||
* Calculate the full file name from dir, shortname and ext
|
||||
* @param dir = path (can be empty)
|
||||
* @param shortname = filename with or without path and/or extension
|
||||
* @param ext = extension (can be empty)
|
||||
* If shortname has an absolute path, or a path start by ./ , the path will not be modified
|
||||
* If shortname has an extension, it will not be modified
|
||||
* @return full filename
|
||||
*/
|
||||
{
|
||||
wxString fullfilename;
|
||||
|
@ -166,31 +167,34 @@ wxString MakeFileName( const wxString& dir,
|
|||
|
||||
if( !dir.IsEmpty() )
|
||||
{
|
||||
if( !shortname.Contains( UNIX_STRING_DIR_SEP ) && !shortname.Contains( WIN_STRING_DIR_SEP )
|
||||
&& !shortname.Contains( wxT( ":" ) ) )
|
||||
{ /* aucun chemin n'est donne */
|
||||
if( !wxIsAbsolutePath( shortname ) )
|
||||
{
|
||||
wxString left = shortname.Left(2);
|
||||
if( left != wxT("./") )
|
||||
{ /* no absolute path in shortname */
|
||||
fullfilename = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fullfilename += shortname;
|
||||
fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||
|
||||
/* Placement de l'extension s'il n'y en a pas deja une */
|
||||
/* Add an extension if shortname has no extension */
|
||||
if( ext.IsEmpty() )
|
||||
return fullfilename;
|
||||
|
||||
/* Recherche d'une eventuelle extension */
|
||||
ii = fullfilename.Length(); /* Pointe la fin du texte */
|
||||
/* search for an extension */
|
||||
ii = fullfilename.Length(); /* Get the end of name */
|
||||
for( ; ii >= 0; ii-- )
|
||||
{
|
||||
if( fullfilename.GetChar( ii ) == '/' )
|
||||
{
|
||||
/* Pas d'extension: placement de l'extension standard */
|
||||
/* not extension: add ext */
|
||||
fullfilename += ext;
|
||||
break;
|
||||
}
|
||||
if( fullfilename.GetChar( ii ) == '.' ) /* extension trouvee */
|
||||
if( fullfilename.GetChar( ii ) == '.' ) /* extension exists, do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -202,7 +206,10 @@ wxString MakeFileName( const wxString& dir,
|
|||
void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt )
|
||||
/**************************************************************************/
|
||||
|
||||
/* Change l'extension du "filename FullFileName" en NewExt.
|
||||
/** Function ChangeFileNameExt
|
||||
* change the extension of FullFileName to NewExt.
|
||||
* @param FullFileName = filename to modify
|
||||
* @param NewExt = new extension for FullFileName
|
||||
*/
|
||||
{
|
||||
wxString FileName;
|
||||
|
@ -223,7 +230,9 @@ void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt )
|
|||
void AddDelimiterString( wxString& string )
|
||||
/*******************************************/
|
||||
|
||||
/* ajoute un " en debut et fin de string s'il n'y en a pas deja.
|
||||
/** Function AddDelimiterString
|
||||
* Add un " to the start and the end of string (if not already done).
|
||||
* @param string = string to modify
|
||||
*/
|
||||
{
|
||||
wxString text;
|
||||
|
@ -237,9 +246,9 @@ void AddDelimiterString( wxString& string )
|
|||
}
|
||||
|
||||
|
||||
/*************************************/
|
||||
/* Fonction de selection de Repertoires */
|
||||
/*************************************/
|
||||
/***********************************/
|
||||
/* Selection Directory dialog box: */
|
||||
/***********************************/
|
||||
|
||||
bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre */
|
||||
wxString& Path, /* Chemin par defaut */
|
||||
|
@ -300,7 +309,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
|
|||
defaultname,
|
||||
Ext,
|
||||
Mask,
|
||||
flag,/* options d'affichage (wxFD_OPEN, wxFD_SAVE .. */
|
||||
flag,/* open mode wxFD_OPEN, wxFD_SAVE .. */
|
||||
Frame,
|
||||
Pos.x, Pos.y );
|
||||
|
||||
|
@ -314,9 +323,9 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
|
|||
/********************************************************/
|
||||
wxString FindKicadHelpPath()
|
||||
/********************************************************/
|
||||
/* Find absolute path for kicad/help (or kicad/help/<language>) */
|
||||
|
||||
/* Find path kicad/help/xx/ ou kicad/help/:
|
||||
/** Function FindKicadHelpPath
|
||||
* Find an absolute path for kicad/help (or kicad/help/<language>)
|
||||
* Find path kicad/help/xx/ ou kicad/help/:
|
||||
* from BinDir
|
||||
* else from environment variable KICAD
|
||||
* else from one of s_HelpPathList
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***********************************************************/
|
||||
/* Module to handle libraries (first part - file and io). */
|
||||
/***********************************************************/
|
||||
/*****************************************************************/
|
||||
/* Functions to handle component library files : read functions */
|
||||
/*****************************************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "gr_basic.h"
|
||||
|
@ -13,10 +13,7 @@
|
|||
|
||||
#include "protos.h"
|
||||
|
||||
/* Variables Locales */
|
||||
|
||||
/* Fonctions locales */
|
||||
/* pour librairies de composants */
|
||||
/* Local Functions */
|
||||
static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f,
|
||||
char* Line, int* LineNum );
|
||||
static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line );
|
||||
|
@ -27,22 +24,18 @@ static bool ReadLibEntryDateAndTime( EDA_LibComponentStruct* Lib
|
|||
static int AddFootprintFilterList( EDA_LibComponentStruct* LibEntryLibEntry,
|
||||
FILE* f, char* Line, int* LineNum );
|
||||
|
||||
/* pour doc librairies */
|
||||
|
||||
|
||||
/****************************************************/
|
||||
/* Routines de lecture des librairies de composants */
|
||||
/****************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Routine to load the given library name. FullLibName should hold full path *
|
||||
* of file name to open, while LibName should hold only its name. *
|
||||
* IF library already exists, it is NOT reloaded. *
|
||||
* return: new lib or NULL *
|
||||
*****************************************************************************/
|
||||
/*************************************************************************************/
|
||||
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
|
||||
const wxString& FullLibName, const wxString& LibName )
|
||||
/*************************************************************************************/
|
||||
|
||||
/** Function LoadLibraryName
|
||||
* Routine to load the given library name. FullLibName should hold full path
|
||||
* of file name to open, while LibName should hold only its name.
|
||||
* IF library already exists, it is NOT reloaded.
|
||||
* @return : new lib or NULL
|
||||
*/
|
||||
{
|
||||
int NumOfParts;
|
||||
FILE* f;
|
||||
|
@ -103,8 +96,9 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
|
|||
void LoadLibraries( WinEDA_DrawFrame* frame )
|
||||
/******************************************/
|
||||
|
||||
/* Delete toutes les librairies chargees et recree toutes les librairies
|
||||
* donnes dans la liste g_LibName_List
|
||||
/* Function LoadLibraries
|
||||
* Clear all alredy loaded librries and load all librairies
|
||||
* given in g_LibName_List
|
||||
*/
|
||||
{
|
||||
wxString FullLibName, msg;
|
||||
|
@ -140,6 +134,7 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
|
|||
FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer );
|
||||
|
||||
msg = wxT( "Loading " ) + FullLibName;
|
||||
frame->PrintMsg( msg );
|
||||
|
||||
if( LoadLibraryName( frame, FullLibName, LibName ) )
|
||||
msg += wxT( " OK" );
|
||||
|
@ -198,10 +193,13 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Routine to free a library from the current loaded libraries. *
|
||||
*****************************************************************************/
|
||||
/**************************************************************/
|
||||
void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
|
||||
/**************************************************************/
|
||||
|
||||
/** Function FreeCmpLibrary
|
||||
* Routine to remove and free a library from the current loaded libraries.
|
||||
*/
|
||||
{
|
||||
int NumOfLibs = NumOfLibraries();
|
||||
LibraryStruct* Lib, * TempLib;
|
||||
|
@ -234,7 +232,8 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
|
|||
|
||||
delete Lib;
|
||||
|
||||
/* La librairie supprimee est peut etre celle selectee dans libedit */
|
||||
/* The removed librairy can be the current library in libedit.
|
||||
* If so, clear the current library in libedit */
|
||||
if( Lib == CurrentLib )
|
||||
CurrentLib = NULL;
|
||||
}
|
||||
|
@ -244,7 +243,8 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
|
|||
const wxChar** GetLibNames()
|
||||
/******************************/
|
||||
|
||||
/* Routine to return pointers to all library names.
|
||||
/** GetLibNames()
|
||||
* Routine to return pointers to all library names.
|
||||
* User is responsible to deallocate memory
|
||||
*/
|
||||
{
|
||||
|
@ -264,10 +264,10 @@ const wxChar** GetLibNames()
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Routine to compare two EDA_LibComponentStruct for the PriorQue module. *
|
||||
* Comparison (insensitive case) is based on Part name. *
|
||||
*****************************************************************************/
|
||||
/** Function LibraryEntryCompare
|
||||
* Routine to compare two EDA_LibComponentStruct for the PriorQue module.
|
||||
* Comparison (insensitive case) is based on Part name.
|
||||
*/
|
||||
int LibraryEntryCompare( EDA_LibComponentStruct* LE1, EDA_LibComponentStruct* LE2 )
|
||||
{
|
||||
return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text );
|
||||
|
@ -397,7 +397,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
|
|||
|
||||
return NULL;
|
||||
}
|
||||
else /* Mise a jour des infos de la ligne "DEF" */
|
||||
else /* Update infos read from the line "DEF" */
|
||||
{
|
||||
LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE;
|
||||
LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE;
|
||||
|
@ -433,11 +433,11 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
|
|||
}
|
||||
}
|
||||
|
||||
/* Analyse lignes suivantes */
|
||||
/* Read next lines */
|
||||
while( GetLine( f, Line, LineNum, 1024 ) )
|
||||
{
|
||||
p = strtok( Line, " \t\n" );
|
||||
Res = TRUE; /* Pour test d'erreur (Res = FALSE = erreur) */
|
||||
Res = TRUE; /* This is the error flag ( if an error occurs, Res = FALSE) */
|
||||
|
||||
if( (Line[0] == 'T') && (Line[1] == 'i') )
|
||||
{
|
||||
|
@ -470,7 +470,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
|
|||
frame->PrintMsg( Msg );
|
||||
}
|
||||
|
||||
/* Fin analyse de la ligne ou block: test de l'info lue */
|
||||
/* End line or block analysis: test for an error */
|
||||
if( !Res )
|
||||
{ /* Something went wrong there. */
|
||||
Msg.Printf( wxT( " Error Line %d, Library not loaded" ), *LineNum );
|
||||
|
@ -545,12 +545,12 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
|
|||
NORMALIZE_ANGLE( Arc->t1 );
|
||||
NORMALIZE_ANGLE( Arc->t2 );
|
||||
|
||||
if( nbarg >= 13 ) // Coord reelles des extremites de l'arc lues
|
||||
if( nbarg >= 13 ) // Actual Coordinates of arc ends are read from file
|
||||
{
|
||||
Arc->m_ArcStart.x = startx; Arc->m_ArcStart.y = starty;
|
||||
Arc->m_ArcEnd.x = endx; Arc->m_ArcEnd.y = endy;
|
||||
}
|
||||
else
|
||||
else // Actual Coordinates of arc ends are not read from file (old library), calculate them
|
||||
{
|
||||
Arc->m_ArcStart.x = Arc->m_Rayon; Arc->m_ArcStart.y = 0;
|
||||
Arc->m_ArcEnd.x = Arc->m_Rayon; Arc->m_ArcEnd.y = 0;
|
||||
|
@ -716,7 +716,6 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue