30#include <wx/filename.h>
31#include <wx/snglinst.h>
34std::unique_ptr<wxSingleInstanceChecker>
LockFile(
const wxString& aFileName )
38 wxFileName fn( aFileName );
42 wxString lockFileName = fn.GetFullPath() +
".lock";
44 lockFileName.Replace(
"/",
"_" );
47 lockFileName.Replace(
"\\",
"_" );
51 if( p->IsAnotherRunning() )
61 lockpath.AssignDir( wxGetHomeDir() );
63#if defined( __WXMAC__ )
65 lockpath.AppendDir(
"Library" );
66 lockpath.AppendDir(
"Caches" );
67 lockpath.AppendDir(
"kicad" );
68#elif defined( __UNIX__ )
71 if( wxGetEnv(
"XDG_RUNTIME_DIR", &envstr ) && !envstr.IsEmpty() )
73 lockpath.AssignDir( envstr );
75 else if( wxGetEnv(
"XDG_CACHE_HOME", &envstr ) && !envstr.IsEmpty() )
77 lockpath.AssignDir( envstr );
82 lockpath.AppendDir(
".cache" );
88#if defined( __WXMAC__ ) || defined( __UNIX__ )
89 if( !lockpath.DirExists() )
92 lockpath.Mkdir( 0700, wxPATH_MKDIR_FULL );
95 return lockpath.GetPath();
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
std::unique_ptr< wxSingleInstanceChecker > LockFile(const wxString &aFileName)
Test to see if aFileName can be locked (is not already locked) and only then returns a wxSingleInstan...
wxString GetKicadLockFilePath()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.