28 #include <wx/filename.h> 29 #include <wx/snglinst.h> 33 std::unique_ptr<wxSingleInstanceChecker>
LockFile(
const wxString& aFileName )
37 wxFileName fn( aFileName );
41 wxString lockFileName = fn.GetFullPath() +
".lock";
43 lockFileName.Replace(
"/",
"_" );
46 lockFileName.Replace(
"\\",
"_" );
48 auto p = std::make_unique<wxSingleInstanceChecker>( lockFileName,
51 if( p->IsAnotherRunning() )
63 lockpath.AssignDir( wxGetHomeDir() );
65 #if defined( __WXMAC__ ) 67 lockpath.AppendDir(
"Library" );
68 lockpath.AppendDir(
"Caches" );
69 lockpath.AppendDir(
"kicad" );
70 #elif defined( __UNIX__ ) 73 if( wxGetEnv(
"XDG_RUNTIME_DIR", &envstr ) && !envstr.IsEmpty() )
75 lockpath.AssignDir( envstr );
77 else if( wxGetEnv(
"XDG_CACHE_HOME", &envstr ) && !envstr.IsEmpty() )
79 lockpath.AssignDir( envstr );
84 lockpath.AppendDir(
".cache" );
90 #if defined( __WXMAC__ ) || defined( __UNIX__ ) 91 if( !lockpath.DirExists() )
94 lockpath.Mkdir( 0700, wxPATH_MKDIR_FULL );
97 return lockpath.GetPath();
wxString GetKicadLockFilePath()
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...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.