diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp index aa84ce6bc1..ba2dc28339 100644 --- a/src/corelib/io/qlockfile.cpp +++ b/src/corelib/io/qlockfile.cpp @@ -150,6 +150,14 @@ QLockFile::~QLockFile() unlock(); } +/*! + * Returns the file name of the lock file + */ +QString QLockFile::fileName() const +{ + return d_ptr->fileName; +} + /*! Sets \a staleLockTime to be the time in milliseconds after which a lock file is considered stale. diff --git a/src/corelib/io/qlockfile.h b/src/corelib/io/qlockfile.h index 8b94900901..ba955241b6 100644 --- a/src/corelib/io/qlockfile.h +++ b/src/corelib/io/qlockfile.h @@ -53,6 +53,8 @@ public: QLockFile(const QString &fileName); ~QLockFile(); + QString fileName() const; + bool lock(); bool tryLock(int timeout = 0); void unlock(); diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 708716e7e2..54d2182e5c 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -96,6 +96,7 @@ void tst_QLockFile::lockUnlock() const QString fileName = dir.path() + "/lock1"; QVERIFY(!QFile(fileName).exists()); QLockFile lockFile(fileName); + QCOMPARE(lockFile.fileName(), fileName); QVERIFY(lockFile.lock()); QVERIFY(lockFile.isLocked()); QCOMPARE(int(lockFile.error()), int(QLockFile::NoError));