diff options
Diffstat (limited to 'tests/auto/qsharedmemory/src')
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock_p.h | 1 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock_unix.cpp | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qsharedmemory/src/qsystemlock_p.h b/tests/auto/qsharedmemory/src/qsystemlock_p.h index 0259d0a..b40a06d 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_p.h +++ b/tests/auto/qsharedmemory/src/qsystemlock_p.h @@ -47,6 +47,7 @@ #include "qsystemlock.h" #include "private/qsharedmemory_p.h" +#include <sys/types.h> #define MAX_LOCKS 64 diff --git a/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp b/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp index e17d03c..a752ba0 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp +++ b/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp @@ -51,6 +51,7 @@ #include <fcntl.h> #include <errno.h> #include <sys/shm.h> +#include <unistd.h> #include <sys/sem.h> // We have to define this as on some sem.h will have it @@ -62,6 +63,25 @@ union qt_semun { #define tr(x) QT_TRANSLATE_NOOP(QLatin1String("QSystemLock"), (x)) +#if defined(Q_OS_SYMBIAN) +int createUnixKeyFile(const QString &fileName) +{ + if (QFile::exists(fileName)) + return 0; + + int fd = open(QFile::encodeName(fileName).constData(), + O_EXCL | O_CREAT | O_RDWR, 0640); + if (-1 == fd) { + if (errno == EEXIST) + return 0; + return -1; + } else { + close(fd); + } + return 1; +} +#endif + QSystemLockPrivate::QSystemLockPrivate() : semaphore(-1), lockCount(0), error(QSystemLock::NoError), unix_key(-1), createdFile(false), createdSemaphore(false) @@ -105,7 +125,11 @@ key_t QSystemLockPrivate::handle() } // Create the file needed for ftok +#if defined(Q_OS_SYMBIAN) + int built = createUnixKeyFile(fileName); +#else int built = QSharedMemoryPrivate::createUnixKeyFile(fileName); +#endif if (-1 == built) return -1; createdFile = (1 == built); |