Use Unix notation for paths and filenames in .pro files

This commit is contained in:
jean-pierre charras 2011-02-26 09:35:22 +01:00
parent 08f3c56d88
commit 90dc2908bd
5 changed files with 80 additions and 7 deletions

View File

@ -696,6 +696,50 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig )
} }
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_FILENAME, group )
{
m_Pt_param = ptparam;
}
/** ReadParam
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig )
{
if( m_Pt_param == NULL || aConfig == NULL )
return;
wxString prm = aConfig->Read( m_Ident );
// filesnames are stored using Unix notation
// under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__
prm.Replace(wxT("/"), wxT("\\"));
#endif
*m_Pt_param = prm;
}
/** SaveParam
* save the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig )
{
if( m_Pt_param == NULL || aConfig == NULL )
return;
wxString prm = *m_Pt_param;
// filenames are stored using Unix notation
prm.Replace(wxT("\\"), wxT("/") );
aConfig->Write( m_Ident, prm );
}
PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident, PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
wxArrayString* ptparam, wxArrayString* ptparam,
const wxChar* group ) : const wxChar* group ) :
@ -725,6 +769,12 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
libname = aConfig->Read( id_lib, wxT( "" ) ); libname = aConfig->Read( id_lib, wxT( "" ) );
if( libname.IsEmpty() ) if( libname.IsEmpty() )
break; break;
// filesnames are stored using Unix notation
// under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__
libname.Replace(wxT("/"), wxT("\\"));
#endif
libname_list->Add( libname ); libname_list->Add( libname );
} }
} }
@ -742,12 +792,16 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig )
unsigned indexlib = 0; unsigned indexlib = 0;
wxString configkey; wxString configkey;
wxString libname;
for( ; indexlib < libname_list->GetCount(); indexlib++ ) for( ; indexlib < libname_list->GetCount(); indexlib++ )
{ {
configkey = m_Ident; configkey = m_Ident;
// We use indexlib+1 because first lib name is LibName1 // We use indexlib+1 because first lib name is LibName1
configkey << (indexlib + 1); configkey << (indexlib + 1);
aConfig->Write( configkey, libname_list->Item( indexlib ) ); libname = libname_list->Item( indexlib );
// filenames are stored using Unix notation
libname.Replace(wxT("\\"), wxT("/") );
aConfig->Write( configkey, libname );
} }
} }

View File

@ -40,7 +40,7 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
GROUPEQU ) ); GROUPEQU ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetIExt" ), m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetIExt" ),
&m_NetlistFileExtension ) ); &m_NetlistFileExtension ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LibDir" ), m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
&m_UserLibraryPath, &m_UserLibraryPath,
GROUPLIB ) ); GROUPLIB ) );

View File

@ -1,6 +1,6 @@
/******************/ /**
/** eeconfig.cpp **/ * @file eeschema_config.cpp
/******************/ */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
@ -265,7 +265,7 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters( void )
if( !m_projectFileParams.empty() ) if( !m_projectFileParams.empty() )
return m_projectFileParams; return m_projectFileParams;
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LibDir" ), m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
&m_UserLibraryPath ) ); &m_UserLibraryPath ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&m_ComponentLibFiles, &m_ComponentLibFiles,

View File

@ -20,6 +20,7 @@ enum paramcfg_id
PARAM_BOOL, PARAM_BOOL,
PARAM_LIBNAME_LIST, PARAM_LIBNAME_LIST,
PARAM_WXSTRING, PARAM_WXSTRING,
PARAM_FILENAME,
PARAM_COMMAND_ERASE, PARAM_COMMAND_ERASE,
PARAM_FIELDNAME_LIST PARAM_FIELDNAME_LIST
}; };
@ -174,6 +175,24 @@ public:
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig );
}; };
/**
* Configuration parameter - PARAM_CFG_FILENAME Class
* Same as PARAM_CFG_WXSTRING, but stores "\" as "/".
* and replace "/" by "\" under Windows.
* Used to store paths and filenames in config files
*/
class PARAM_CFG_FILENAME : public PARAM_CFG_BASE
{
public:
wxString* m_Pt_param; ///< Pointer to the parameter value
public:
PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
};
class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE
{ {

View File

@ -202,7 +202,7 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters()
if( !m_projectFileParams.empty() ) if( !m_projectFileParams.empty() )
return m_projectFileParams; return m_projectFileParams;
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LibDir" ),&g_UserLibDirBuffer, m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),&g_UserLibDirBuffer,
GROUPLIB ) ); GROUPLIB ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), &g_LibName_List, m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), &g_LibName_List,
GROUPLIB ) ); GROUPLIB ) );