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:229
void setDirToLock(const FilePath &dir) noexcept
Specify the directory for which you need the lock.
Definition: directorylock.cpp:64
bool unlockIfLocked()
Unlock the specified directory if it was locked by this object.
Definition: directorylock.cpp:178
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:216
void lock()
Lock the specified directory (create/update the lock file)
Definition: directorylock.cpp:187
LockStatus
The return type of getStatus()
Definition: directorylock.h:163
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:41
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:74
void tryLock(LockHandlerCallback lockHandler=nullptr)
Lock the specified directory if not already locked.
Definition: directorylock.cpp:152
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
Definition: occmodel.cpp:77