KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LOCKFILE Class Reference

#include <lockfile.h>

Public Member Functions

 LOCKFILE (const wxString &filename, bool aRemoveOnRelease=true)
 
 LOCKFILE (LOCKFILE &&other) noexcept
 
 ~LOCKFILE ()
 
void UnlockFile ()
 Unlock and remove the file from the filesystem as long as we still own it.
 
bool OverrideLock (bool aRemoveOnRelease=true)
 Force the lock, overwriting the data that existed already.
 
bool IsLockedByMe ()
 
wxString GetUsername ()
 
wxString GetHostname ()
 
wxString GetErrorMsg ()
 
bool Locked () const
 
bool Valid () const
 
 operator bool () const
 

Private Member Functions

bool checkUserAndHost ()
 

Private Attributes

wxString m_originalFile
 
wxString m_lockFilename
 
wxString m_username
 
wxString m_hostname
 
bool m_fileCreated
 
bool m_status
 
bool m_removeOnRelease
 
wxString m_errorMsg
 

Detailed Description

Definition at line 42 of file lockfile.h.

Constructor & Destructor Documentation

◆ LOCKFILE() [1/2]

LOCKFILE::LOCKFILE ( const wxString & filename,
bool aRemoveOnRelease = true )
inline

◆ LOCKFILE() [2/2]

LOCKFILE::LOCKFILE ( LOCKFILE && other)
inlinenoexcept

Definition at line 141 of file lockfile.h.

References LOCKFILE().

◆ ~LOCKFILE()

LOCKFILE::~LOCKFILE ( )
inline

Definition at line 155 of file lockfile.h.

References UnlockFile().

Member Function Documentation

◆ checkUserAndHost()

bool LOCKFILE::checkUserAndHost ( )
inlineprivate

Definition at line 288 of file lockfile.h.

References LCK, m_hostname, m_lockFilename, and m_username.

Referenced by UnlockFile().

◆ GetErrorMsg()

wxString LOCKFILE::GetErrorMsg ( )
inline
Returns
Last error message generated.

Definition at line 261 of file lockfile.h.

References m_errorMsg.

◆ GetHostname()

wxString LOCKFILE::GetHostname ( )
inline
Returns
Current hostname. If we own the lock this is our computer. Otherwise, this is the computer that does.

Definition at line 256 of file lockfile.h.

References m_hostname.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_MANAGER_FRAME::LoadProject(), and KICAD_MANAGER_FRAME::ProjectChanged().

◆ GetUsername()

wxString LOCKFILE::GetUsername ( )
inline
Returns
Current username. If we own the lock, this is us. Otherwise, this is the user that does own it.

Definition at line 250 of file lockfile.h.

References m_username.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_MANAGER_FRAME::LoadProject(), and KICAD_MANAGER_FRAME::ProjectChanged().

◆ IsLockedByMe()

bool LOCKFILE::IsLockedByMe ( )
inline

◆ Locked()

bool LOCKFILE::Locked ( ) const
inline

Definition at line 263 of file lockfile.h.

References m_fileCreated.

Referenced by BOOST_AUTO_TEST_CASE().

◆ operator bool()

LOCKFILE::operator bool ( ) const
inlineexplicit

Definition at line 273 of file lockfile.h.

References m_status.

◆ OverrideLock()

bool LOCKFILE::OverrideLock ( bool aRemoveOnRelease = true)
inline

Force the lock, overwriting the data that existed already.

Returns
True if we successfully overrode the lock

Definition at line 183 of file lockfile.h.

References LCK, m_errorMsg, m_fileCreated, m_hostname, m_lockFilename, m_removeOnRelease, m_status, and m_username.

Referenced by BOOST_AUTO_TEST_CASE(), KICAD_MANAGER_FRAME::LoadProject(), and KICAD_MANAGER_FRAME::ProjectChanged().

◆ UnlockFile()

void LOCKFILE::UnlockFile ( )
inline

Unlock and remove the file from the filesystem as long as we still own it.

Definition at line 163 of file lockfile.h.

References checkUserAndHost(), LCK, m_errorMsg, m_fileCreated, m_lockFilename, m_removeOnRelease, and m_status.

Referenced by ~LOCKFILE().

◆ Valid()

Member Data Documentation

◆ m_errorMsg

wxString LOCKFILE::m_errorMsg
private

Definition at line 286 of file lockfile.h.

Referenced by GetErrorMsg(), LOCKFILE(), OverrideLock(), and UnlockFile().

◆ m_fileCreated

bool LOCKFILE::m_fileCreated
private

Definition at line 283 of file lockfile.h.

Referenced by Locked(), LOCKFILE(), OverrideLock(), and UnlockFile().

◆ m_hostname

wxString LOCKFILE::m_hostname
private

Definition at line 282 of file lockfile.h.

Referenced by checkUserAndHost(), GetHostname(), IsLockedByMe(), LOCKFILE(), and OverrideLock().

◆ m_lockFilename

wxString LOCKFILE::m_lockFilename
private

Definition at line 280 of file lockfile.h.

Referenced by checkUserAndHost(), LOCKFILE(), OverrideLock(), and UnlockFile().

◆ m_originalFile

wxString LOCKFILE::m_originalFile
private

Definition at line 279 of file lockfile.h.

Referenced by LOCKFILE().

◆ m_removeOnRelease

bool LOCKFILE::m_removeOnRelease
private

Definition at line 285 of file lockfile.h.

Referenced by LOCKFILE(), OverrideLock(), and UnlockFile().

◆ m_status

bool LOCKFILE::m_status
private

Definition at line 284 of file lockfile.h.

Referenced by LOCKFILE(), operator bool(), OverrideLock(), UnlockFile(), and Valid().

◆ m_username

wxString LOCKFILE::m_username
private

Definition at line 281 of file lockfile.h.

Referenced by checkUserAndHost(), GetUsername(), IsLockedByMe(), LOCKFILE(), and OverrideLock().


The documentation for this class was generated from the following file: