20 #ifndef LIBREPCB_CORE_DIRECTORYLOCK_H 21 #define LIBREPCB_CORE_DIRECTORYLOCK_H 192 const QString& user)>
void lock()
Lock the specified directory (create/update the lock file)
Definition: directorylock.cpp:187
const FilePath & getLockFilepath() const noexcept
Get the filepath of the lock file (NOT the directory to lock!)
Definition: directorylock.h:256
The directory is locked by another user or machine.
FilePath mLockFilePath
The filepath to the lock file.
Definition: directorylock.h:350
Definition: occmodel.cpp:77
The directory is locked by another application instance on this machine.
The directory is locked by this application instance.
DirectoryLock() noexcept
The default constructor.
Definition: directorylock.cpp:41
void tryLock(LockHandlerCallback lockHandler=nullptr)
Lock the specified directory if not already locked.
Definition: directorylock.cpp:152
bool mLockedByThisObject
This attribute defines if the lock is active by this object.
Definition: directorylock.h:365
The directory is not locked (lock file does not exist).
The directory is locked by a crashed application instance.
FilePath mDirToLock
The filepath to the directory to lock (passed by setDirToLock())
Definition: directorylock.h:342
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
bool unlockIfLocked()
Unlock the specified directory if it was locked by this object.
Definition: directorylock.cpp:178
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
void setDirToLock(const FilePath &dir) noexcept
Specify the directory for which you need the lock.
Definition: directorylock.cpp:64
The directory is locked by an unknown application (may be stale).
DirectoryLock & operator=(const DirectoryLock &rhs)=delete
const FilePath & getDirToLock() const noexcept
Get the filepath of the directory to lock (passed by setDirToLock())
Definition: directorylock.h:248
static QSet< FilePath > & dirsLockedByThisAppInstance() noexcept
Get the global set of filepaths locked by this application instance.
Definition: directorylock.cpp:229
LockStatus
The return type of getStatus()
Definition: directorylock.h:163
LockStatus getStatus(QString *lockedByUser=nullptr) const
Get the lock status of the specified directory.
Definition: directorylock.cpp:74
void unlock()
Unlock the specified directory (remove the lock file)
Definition: directorylock.cpp:216
This class can be used to implement file-based directory locks.
Definition: directorylock.h:154