Falkon Develop
Cross-platform Qt-based web browser
QtLP_Private::QtLockedFile Class Reference

#include <qtlockedfile.h>

Inheritance diagram for QtLP_Private::QtLockedFile:

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
 

Detailed Description

Definition at line 67 of file qtlockedfile.h.

Member Enumeration Documentation

◆ LockMode

Enumerator
NoLock 
ReadLock 
WriteLock 

Definition at line 70 of file qtlockedfile.h.

Constructor & Destructor Documentation

◆ QtLockedFile() [1/2]

QtLockedFile::QtLockedFile ( )

Constructs an unlocked QtLockedFile object. This constructor behaves in the same way as QFile::QFile().

See also
QFile::QFile()

Definition at line 83 of file qtlockedfile.cpp.

◆ QtLockedFile() [2/2]

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&).

See also
QFile::QFile()

Definition at line 100 of file qtlockedfile.cpp.

◆ ~QtLockedFile()

QtLockedFile::~QtLockedFile ( )
override

Destroys the QtLockedFile object. If any locks were held, they are released.

Definition at line 110 of file qtlockedfile_unix.cpp.

Member Function Documentation

◆ isLocked()

bool QtLockedFile::isLocked ( ) const

Returns true if this object has a in read or write lock; otherwise returns false.

See also
lockMode()

Definition at line 138 of file qtlockedfile.cpp.

◆ lock()

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.

See also
unlock(), isLocked(), lockMode()

Definition at line 48 of file qtlockedfile_unix.cpp.

◆ lockMode()

QtLockedFile::LockMode QtLockedFile::lockMode ( ) const

Returns the type of lock currently held by this object, or QtLockedFile::NoLock.

See also
isLocked()

Definition at line 149 of file qtlockedfile.cpp.

◆ open()

bool QtLockedFile::open ( OpenMode  mode)
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.

See also
QFile::open(), QFile::resize()

Definition at line 123 of file qtlockedfile.cpp.

◆ unlock()

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.

See also
lock(), isLocked(), lockMode()

Definition at line 84 of file qtlockedfile_unix.cpp.


The documentation for this class was generated from the following files: