LTspice import: add LTspice 17.1 Windows library path.

This commit is contained in:
Alex Shvartzkop 2023-07-12 10:57:30 +05:00
parent c652abecff
commit f8f7b84f13
5 changed files with 47 additions and 5 deletions

View File

@ -86,11 +86,20 @@ SCH_SHEET* SCH_LTSPICE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSche
SYMBOL_LIB_TABLE* libTable = aSchematic->Prj().SchSymbolLibTable();
wxCHECK_MSG( libTable, nullptr, "Could not load symbol lib table." );
wxFileName ltspiceDataDir( KIPLATFORM::ENV::GetUserDataPath(), wxEmptyString );
ltspiceDataDir.RemoveLastDir(); // "kicad"
// Windows path: C:\Users\USERNAME\AppData\Local\LTspice\lib
wxFileName ltspiceDataDir( KIPLATFORM::ENV::GetUserLocalDataPath(), wxEmptyString );
ltspiceDataDir.AppendDir( wxS( "LTspice" ) );
ltspiceDataDir.AppendDir( "lib" );
ltspiceDataDir.AppendDir( wxS( "lib" ) );
if( !ltspiceDataDir.DirExists() )
{
// Mac path
wxFileName ltspiceDataDir( KIPLATFORM::ENV::GetUserDataPath(), wxEmptyString );
ltspiceDataDir.RemoveLastDir(); // "kicad"
ltspiceDataDir.AppendDir( wxS( "LTspice" ) );
ltspiceDataDir.AppendDir( wxS( "lib" ) );
}
if( !ltspiceDataDir.DirExists() )
{
@ -100,7 +109,7 @@ SCH_SHEET* SCH_LTSPICE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSche
while( !foundFile.empty() )
{
ltspiceDataDir = wxFileName(foundFile, wxEmptyString);
ltspiceDataDir.AppendDir( "lib" );
ltspiceDataDir.AppendDir( wxS( "lib" ) );
if( ltspiceDataDir.DirExists() )
break;

View File

@ -115,6 +115,12 @@ wxString KIPLATFORM::ENV::GetUserDataPath()
}
wxString KIPLATFORM::ENV::GetUserLocalDataPath()
{
return g_get_user_data_dir();
}
wxString KIPLATFORM::ENV::GetUserCachePath()
{
return g_get_user_cache_dir();

View File

@ -72,6 +72,13 @@ namespace KIPLATFORM
*/
wxString GetUserDataPath();
/**
* Retrieves the operating system specific path for a user's local data store
*
* @return User config path
*/
wxString GetUserLocalDataPath();
/**
* Retrieves the operating system specific path for user's application cache
*

View File

@ -116,6 +116,20 @@ wxString KIPLATFORM::ENV::GetUserDataPath()
}
wxString KIPLATFORM::ENV::GetUserLocalDataPath()
{
// If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get()
// complains about not existing app. so use a dummy app
if( wxTheApp == nullptr )
{
wxApp dummy;
return wxStandardPaths::Get().GetUserLocalDataDir();
}
return wxStandardPaths::Get().GetUserLocalDataDir();
}
wxString KIPLATFORM::ENV::GetUserCachePath()
{
// Unfortunately AppData/Local is the closest analog to "Cache" directories of other platforms

View File

@ -91,6 +91,12 @@ wxString KIPLATFORM::ENV::GetUserDataPath()
}
wxString KIPLATFORM::ENV::GetUserLocalDataPath()
{
return wxStandardPaths::Get().GetUserLocalDataDir();
}
wxString KIPLATFORM::ENV::GetUserCachePath()
{
NSURL* url = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory