6#include "private/qlockfile_p.h"
8#include "QtCore/qtemporaryfile.h"
9#include "QtCore/qfileinfo.h"
10#include "QtCore/qdebug.h"
11#include "QtCore/qdatetime.h"
12#include "QtCore/qfileinfo.h"
13#include "QtCore/qcache.h"
14#include "QtCore/qglobalstatic.h"
15#include "QtCore/qmutex.h"
17#include "private/qcore_unix_p.h"
18#include "private/qabstractfileengine_p.h"
19#include "private/qfilesystementry_p.h"
20#include "private/qtemporaryfile_p.h"
22#if !defined(Q_OS_INTEGRITY)
26#if defined(Q_OS_RTEMS)
36#if defined(Q_OS_MACOS)
38#elif defined(Q_OS_LINUX)
41#elif defined(Q_OS_HAIKU)
42# include <kernel/OS.h>
43#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
44# include <sys/cdefs.h>
45# include <sys/param.h>
46# include <sys/sysctl.h>
47# if !defined(Q_OS_NETBSD)
109#if defined(LOCK_EX) && defined(LOCK_NB)
110 if (flock(
fd, LOCK_EX | LOCK_NB) == -1)
135 const int errnoSaved = errno;
151#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
173 if (::kill(pid_t(pid), 0) == -1 && errno == ESRCH)
190#if defined(Q_OS_MACOS)
192 proc_name(pid,
name,
sizeof(
name) /
sizeof(
char));
194#elif defined(Q_OS_LINUX)
199 sprintf(exePath,
"/proc/%lld/exe", pid);
208 static const char deleted[] =
" (deleted)";
209 if (
buf.endsWith(deleted))
210 buf.chop(strlen(deleted));
213#elif defined(Q_OS_HAIKU)
215 if (get_thread_info(pid, &
info) != B_OK)
218#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
219# if defined(Q_OS_NETBSD)
220 struct kinfo_proc2 kp;
221 int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, (int)pid,
sizeof(
struct kinfo_proc2), 1 };
222# elif defined(Q_OS_OPENBSD)
223 struct kinfo_proc kp;
224 int mib[6] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid,
sizeof(
struct kinfo_proc), 1 };
226 struct kinfo_proc kp;
227 int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid };
229 size_t len =
sizeof(kp);
230 u_int mib_len =
sizeof(mib)/
sizeof(u_int);
232 if (sysctl(mib, mib_len, &kp, &
len, NULL, 0) < 0)
235# if defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD)
240 if (kp.ki_pid != pid)
245#elif defined(Q_OS_QNX)
247 sprintf(exePath,
"/proc/%lld/exefile", pid);
254 if (QT_FSTAT(
fd, &sbuf) == -1) {
277 close(
d->fileHandle);
280 qWarning() <<
"Could not remove our own lock file" <<
d->fileName <<
"maybe permissions changed meanwhile?";
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
\inmodule QtCore \reentrant
bool isSymLink() const
Returns true if this object points to a symbolic link, shortcut, or alias; otherwise returns false.
QString symLinkTarget() const
QString fileName() const
Returns the name of the file, excluding the path.
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Q_AUTOTEST_EXPORT QString fileName() const
bool remove()
Removes the file specified by fileName().
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
QLockFile::LockError tryLock_sys()
static bool isProcessRunning(qint64 pid, const QString &appname)
static Q_CORE_EXPORT QString processNameByPid(qint64 pid)
QByteArray lockFileContents() const
LockError
This enum describes the result of the last call to lock() or tryLock().
void unlock()
Releases the lock, by deleting the lock file.
\macro QT_RESTRICTED_CAST_FROM_ASCII
const QChar * constData() const
Returns a pointer to the data stored in the QString.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
QT_BEGIN_NAMESPACE QByteArray qt_readlink(const char *path)
static qint64 qt_safe_write(int fd, const void *data, qint64 len)
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
static qint64 qt_safe_read(int fd, void *data, qint64 maxlen)
bool qt_haveLinuxProcfs()
static int qt_safe_close(int fd)
static QT_BEGIN_NAMESPACE qint64 qt_write_loop(int fd, const char *data, qint64 len)
static bool setNativeLocks(int fd)
Q_DECL_COLD_FUNCTION Q_CORE_EXPORT QString qt_error_string(int errorCode=-1)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static QString lockFileName(const QString &name)
#define qUtf16Printable(string)
#define QStringLiteral(str)
QFileInfo info(fileName)
[8]
QFileInfo fi("c:/temp/foo")
[newstuff]