|
Krita Source Code Documentation
|
#include <qtlockedfile.h>
Inheritance diagram for QtLP_Private::QtLockedFile:Public Types | |
| enum | LockMode { NoLock = 0 , ReadLock , WriteLock } |
Public Member Functions | |
| bool | isLocked () const |
| bool | lock (LockMode mode, bool block=true) |
| LockMode | lockMode () const |
| bool | open (OpenMode mode) |
| QtLockedFile () | |
| QtLockedFile (const QString &name) | |
| bool | unlock () |
| ~QtLockedFile () | |
Private Attributes | |
| LockMode | m_lock_mode |
Definition at line 14 of file qtlockedfile.h.
| QtLockedFile::QtLockedFile | ( | ) |
Constructs an unlocked QtLockedFile object. This constructor behaves in the same way as QFile::QFile().
Definition at line 46 of file qtlockedfile.cpp.
References m_lock_mode, and NoLock.
| QtLockedFile::QtLockedFile | ( | const QString & | name | ) |
Constructs an unlocked QtLockedFile object with file name. This constructor behaves in the same way as QFile::QFile(const QString&).
Definition at line 63 of file qtlockedfile.cpp.
References m_lock_mode, and NoLock.
| QtLockedFile::~QtLockedFile | ( | ) |
Destroys the QtLockedFile object. If any locks were held, they are released.
Definition at line 73 of file qtlockedfile_unix.cpp.
| bool QtLockedFile::isLocked | ( | ) | const |
Returns true if this object has a in read or write lock; otherwise returns false.
Definition at line 101 of file qtlockedfile.cpp.
References m_lock_mode, and NoLock.
| bool QtLockedFile::lock | ( | LockMode | mode, |
| bool | block = true ) |
Obtains a lock of type mode. The file must be opened before it can be locked.
If block is true, this function will block until the lock is acquired. If block is false, this function returns false immediately if the lock cannot be acquired.
If this object already has a lock of type mode, this function returns true immediately. If this object has a lock of a different type than mode, the lock is first released and then a new lock is obtained.
This function returns true if, after it executes, the file is locked by this object, and false otherwise.
Definition at line 11 of file qtlockedfile_unix.cpp.
| QtLockedFile::LockMode QtLockedFile::lockMode | ( | ) | const |
Returns the type of lock currently held by this object, or QtLockedFile::NoLock.
Definition at line 112 of file qtlockedfile.cpp.
References m_lock_mode.
| bool QtLockedFile::open | ( | OpenMode | mode | ) |
Opens the file in OpenMode mode.
This is identical to QFile::open(), with the one exception that the Truncate mode flag is disallowed. Truncation would conflict with the advisory file locking, since the file would be modified before the write lock is obtained. If truncation is required, use resize(0) after obtaining the write lock.
Returns true if successful; otherwise false.
Definition at line 86 of file qtlockedfile.cpp.
| bool QtLockedFile::unlock | ( | ) |
Releases a lock.
If the object has no lock, this function returns immediately.
This function returns true if, after it executes, the file is not locked by this object, and false otherwise.
Definition at line 47 of file qtlockedfile_unix.cpp.
|
private |
Definition at line 41 of file qtlockedfile.h.