20#ifndef LIBREPCB_CORE_DIRECTORYLOCK_H
21#define LIBREPCB_CORE_DIRECTORYLOCK_H
192 const QString& user)>
This class can be used to implement file-based directory locks.
Definition directorylock.h:154
FilePath mDirToLock
The filepath to the directory to lock (passed by setDirToLock())
Definition directorylock.h:342
static QSet< FilePath > & dirsLockedByThisAppInstance() noexcept
Get the global set of filepaths locked by this application instance.
Definition directorylock.cpp:228
void setDirToLock(const FilePath &dir) noexcept
Specify the directory for which you need the lock.
Definition directorylock.cpp:63
bool unlockIfLocked()
Unlock the specified directory if it was locked by this object.
Definition directorylock.cpp:177
const FilePath & getLockFilepath() const noexcept
Get the filepath of the lock file (NOT the directory to lock!)
Definition directorylock.h:256
DirectoryLock & operator=(const DirectoryLock &rhs)=delete
std::function< bool(const FilePath &dir, LockStatus status, const QString &user)> LockHandlerCallback
Callback type used to determine whether a lock should be overridden or not.
Definition directorylock.h:193
void unlock()
Unlock the specified directory (remove the lock file)
Definition directorylock.cpp:215
void lock()
Lock the specified directory (create/update the lock file)
Definition directorylock.cpp:186
LockStatus
The return type of getStatus()
Definition directorylock.h:163
@ LockedByThisApp
The directory is locked by this application instance.
@ LockedByOtherUser
The directory is locked by another user or machine.
@ LockedByUnknownApp
The directory is locked by an unknown application (may be stale).
@ Unlocked
The directory is not locked (lock file does not exist).
@ StaleLock
The directory is locked by a crashed application instance.
@ LockedByOtherApp
The directory is locked by another application instance on this machine.
const FilePath & getDirToLock() const noexcept
Get the filepath of the directory to lock (passed by setDirToLock())
Definition directorylock.h:248
DirectoryLock() noexcept
The default constructor.
Definition directorylock.cpp:40
FilePath mLockFilePath
The filepath to the lock file.
Definition directorylock.h:350
bool mLockedByThisObject
This attribute defines if the lock is active by this object.
Definition directorylock.h:365
LockStatus getStatus(QString *lockedByUser=nullptr) const
Get the lock status of the specified directory.
Definition directorylock.cpp:73
void tryLock(LockHandlerCallback lockHandler=nullptr)
Lock the specified directory if not already locked.
Definition directorylock.cpp:151
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
Definition occmodel.cpp:76