3D Viewer: change 3D model cache path.
* Use platform cache path insted of the KiCad configuration path to write the 3D model cache. * OSX: ${HOME}/Library/Caches/kicad/3d * Linux: ${XDG_CACHE_HOME}/kicad/3d or ${HOME}/.cache/kicad/3d * Windows: AppData\Local\kicad\3d
This commit is contained in:
parent
f5fa6a2148
commit
c11b0cef99
|
@ -39,6 +39,7 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
#include "common.h"
|
||||
#include "3d_cache.h"
|
||||
#include "3d_info.h"
|
||||
#include "common.h"
|
||||
|
@ -584,7 +585,32 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
|
|||
#endif
|
||||
}
|
||||
|
||||
cfgdir.AppendDir( wxT( "cache" ) );
|
||||
// 3D cache data must go to a user's cache directory;
|
||||
// unfortunately wxWidgets doesn't seem to provide
|
||||
// functions to retrieve such a directory.
|
||||
//
|
||||
// 1. OSX: ~/Library/Caches/kicad/3d/
|
||||
// 2. Linux: ${XDG_CACHE_HOME}/kicad/3d ~/.cache/kicad/3d/
|
||||
// 3. MSWin: AppData\Local\kicad\3d
|
||||
wxString cacheDir;
|
||||
|
||||
#if defined(_WIN32)
|
||||
wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
|
||||
cacheDir = wxStandardPaths::Get().GetUserLocalDataDir();
|
||||
cacheDir.append( "\\kicad\\3d" );
|
||||
#elif defined(__APPLE)
|
||||
cacheDir = "${HOME}/Library/Caches/kicad/3d";
|
||||
#else // assume Linux
|
||||
cacheDir = ExpandEnvVarSubstitutions( "${XDG_CACHE_HOME}" );
|
||||
|
||||
if( cacheDir.empty() || cacheDir == "${XDG_CACHE_HOME}" )
|
||||
cacheDir = "${HOME}/.cache";
|
||||
|
||||
cacheDir.append( "/kicad/3d" );
|
||||
#endif
|
||||
|
||||
cacheDir = ExpandEnvVarSubstitutions( cacheDir );
|
||||
cfgdir.Assign( cacheDir, "" );
|
||||
|
||||
if( !cfgdir.DirExists() )
|
||||
{
|
||||
|
@ -628,9 +654,9 @@ wxString S3D_CACHE::Get3DConfigDir( bool createDefault )
|
|||
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
|
||||
|
||||
#if !defined( __WINDOWS__ ) && !defined( __WXMAC__ )
|
||||
wxString envstr = ExpandEnvVarSubstitutions( "XDG_CONFIG_HOME" );
|
||||
wxString envstr = ExpandEnvVarSubstitutions( "${XDG_CONFIG_HOME}" );
|
||||
|
||||
if( envstr.IsEmpty() )
|
||||
if( envstr.IsEmpty() || envstr == "${XDG_CONFIG_HOME}" )
|
||||
{
|
||||
// XDG_CONFIG_HOME is not set, so use the fallback
|
||||
cfgpath.AppendDir( wxT( ".config" ) );
|
||||
|
|
|
@ -133,7 +133,8 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
|||
#endif
|
||||
|
||||
#ifndef _WIN32 // suppress 'kicad' subdir since it is redundant on MSWin
|
||||
fn.Assign( wxStandardPaths::Get().GetPluginsDir() );
|
||||
fn.Assign( wxStandardPaths::Get().GetPluginsDir(), "" );
|
||||
fn.RemoveLastDir();
|
||||
fn.AppendDir( wxT( "kicad" ) );
|
||||
#else
|
||||
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
|
||||
|
@ -148,8 +149,13 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
|||
checkPluginPath( wxT( "/opt/kicad/lib/kicad/plugins/3d" ), searchpaths );
|
||||
|
||||
// note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
|
||||
fn.Assign( wxStandardPaths::Get().GetUserDataDir() );
|
||||
fn.Assign( wxStandardPaths::Get().GetUserDataDir(), "" );
|
||||
fn.RemoveLastDir();
|
||||
#ifdef _WIN32
|
||||
fn.AppendDir( wxT( "kicad" ) );
|
||||
#else
|
||||
fn.AppendDir( wxT( ".kicad" ) );
|
||||
#endif
|
||||
fn.AppendDir( wxT( "plugins" ) );
|
||||
fn.AppendDir( wxT( "3d" ) );
|
||||
checkPluginPath( fn.GetPathWithSep(), searchpaths );
|
||||
|
|
Loading…
Reference in New Issue