#include <memory>
#include <build_version.h>
#include <lockfile.h>
#include <wx/filename.h>
#include <wx/snglinst.h>
Go to the source code of this file.
|
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 wxSingleInstanceChecker protecting aFileName. More...
|
|
wxString | GetKicadLockFilePath () |
|
◆ GetKicadLockFilePath()
wxString GetKicadLockFilePath |
( |
| ) |
|
- Returns
- A wxString containing the path for lockfiles in Kicad.
Definition at line 61 of file lockfile.cpp.
64 lockpath.AssignDir( wxGetHomeDir() );
66 #if defined( __WXMAC__ ) 68 lockpath.AppendDir( wxT(
"Library" ) );
69 lockpath.AppendDir( wxT(
"Caches" ) );
70 lockpath.AppendDir( wxT(
"kicad" ) );
71 #elif defined( __UNIX__ ) 74 if( wxGetEnv( wxT(
"XDG_RUNTIME_DIR" ), &envstr ) && !envstr.IsEmpty() )
76 lockpath.AssignDir( envstr );
78 else if( wxGetEnv( wxT(
"XDG_CACHE_HOME" ), &envstr ) && !envstr.IsEmpty() )
80 lockpath.AssignDir( envstr );
85 lockpath.AppendDir( wxT(
".cache" ) );
91 #if defined( __WXMAC__ ) || defined( __UNIX__ ) 92 if( !lockpath.DirExists() )
95 lockpath.Mkdir( 0700, wxPATH_MKDIR_FULL );
98 return lockpath.GetPath();
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
References Format(), and GetMajorMinorVersion().
Referenced by LockFile().
◆ LockFile()
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 wxSingleInstanceChecker protecting aFileName.
Definition at line 34 of file lockfile.cpp.
38 wxFileName fn( aFileName );
42 wxString lockFileName = fn.GetFullPath() + wxT(
".lock" );
44 lockFileName.Replace( wxT(
"/" ), wxT(
"_" ) );
47 lockFileName.Replace( wxT(
"\\" ), wxT(
"_" ) );
49 auto p = std::make_unique<wxSingleInstanceChecker>( lockFileName,
52 if( p->IsAnotherRunning() )
wxString GetKicadLockFilePath()
References GetKicadLockFilePath().
Referenced by SETTINGS_MANAGER::LoadProject().