summaryrefslogtreecommitdiffstats
path: root/src/libs/kdtools/lockfile_unix.cpp
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-09-01 14:00:17 +0200
committerNiels Weber <niels.weber@theqtcompany.com>2015-09-07 10:41:45 +0000
commitcab3405ad2b0d269924a93263298304bff8807eb (patch)
tree2cc70eac08d78376998e8406ed41211b42598449 /src/libs/kdtools/lockfile_unix.cpp
parent823efa49cc61e91d7deb7b14d0bc05991c142474 (diff)
Missed to rename classes and to update docs and tests.
Change-Id: I2d79ab4094cb9706287d44160543c19b35a66c95 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
Diffstat (limited to 'src/libs/kdtools/lockfile_unix.cpp')
-rw-r--r--src/libs/kdtools/lockfile_unix.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libs/kdtools/lockfile_unix.cpp b/src/libs/kdtools/lockfile_unix.cpp
index d37fc8fb1..a1c8b7056 100644
--- a/src/libs/kdtools/lockfile_unix.cpp
+++ b/src/libs/kdtools/lockfile_unix.cpp
@@ -42,7 +42,9 @@
#include <sys/file.h>
#include <unistd.h>
-bool KDLockFile::Private::lock()
+namespace KDUpdater {
+
+bool LockFile::Private::lock()
{
if (locked)
return true;
@@ -51,7 +53,7 @@ bool KDLockFile::Private::lock()
errno = 0;
handle = open(filename.toLatin1().constData(), O_CREAT | O_RDWR | O_NONBLOCK, 0600);
if (handle == -1) {
- errorString = QCoreApplication::translate("KDLockFile", "Cannot create lock file \"%1\": "
+ errorString = QCoreApplication::translate("LockFile", "Cannot create lock file \"%1\": "
"%2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno)));
return false;
}
@@ -62,7 +64,7 @@ bool KDLockFile::Private::lock()
while (written < data.size()) {
const qint64 n = write(handle, data.constData() + written, data.size() - written);
if (n < 0) {
- errorString = QCoreApplication::translate("KDLockFile", "Cannot write PID to lock "
+ errorString = QCoreApplication::translate("LockFile", "Cannot write PID to lock "
"file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno)));
return false;
}
@@ -71,13 +73,13 @@ bool KDLockFile::Private::lock()
errno = 0;
locked = flock(handle, LOCK_NB | LOCK_EX) != -1;
if (!locked) {
- errorString = QCoreApplication::translate("KDLockFile", "Cannot obtain the lock for "
+ errorString = QCoreApplication::translate("LockFile", "Cannot obtain the lock for "
"file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno)));
}
return locked;
}
-bool KDLockFile::Private::unlock()
+bool LockFile::Private::unlock()
{
errorString.clear();
if (!locked)
@@ -86,10 +88,12 @@ bool KDLockFile::Private::unlock()
errno = 0;
locked = flock(handle, LOCK_UN | LOCK_NB) == -1;
if (locked) {
- errorString = QCoreApplication::translate("KDLockFile", "Cannot release the lock for "
+ errorString = QCoreApplication::translate("LockFile", "Cannot release the lock for "
"file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno)));
} else {
unlink(filename.toLatin1());
}
return !locked;
}
+
+} // namespace KDUpdater