![]() |
Falkon Develop
Cross-platform Qt-based web browser
|
#include <qtlockedfile.h>
Public Types | |
enum | LockMode { NoLock = 0 , ReadLock , WriteLock } |
Public Member Functions | |
QtLockedFile () | |
QtLockedFile (const QString &name) | |
~QtLockedFile () override | |
bool | open (OpenMode mode) override |
bool | lock (LockMode mode, bool block=true) |
bool | unlock () |
bool | isLocked () const |
LockMode | lockMode () const |
Definition at line 67 of file qtlockedfile.h.
Enumerator | |
---|---|
NoLock | |
ReadLock | |
WriteLock |
Definition at line 70 of file qtlockedfile.h.
QtLockedFile::QtLockedFile | ( | ) |
Constructs an unlocked QtLockedFile object. This constructor behaves in the same way as QFile::QFile().
Definition at line 83 of file qtlockedfile.cpp.
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 100 of file qtlockedfile.cpp.
|
override |
Destroys the QtLockedFile object. If any locks were held, they are released.
Definition at line 110 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 138 of file qtlockedfile.cpp.
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 48 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 149 of file qtlockedfile.cpp.
|
override |
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 123 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 84 of file qtlockedfile_unix.cpp.