summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/corelib/io/qfileselector.cpp6
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp12
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp6
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp2
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp3
-rw-r--r--src/corelib/io/qlockfile_unix.cpp14
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/corelib/io/qprocess_unix.cpp3
-rw-r--r--src/corelib/io/qstorageinfo.cpp6
-rw-r--r--src/corelib/io/qstorageinfo_p.h2
-rw-r--r--src/corelib/io/qtextstream.cpp6
-rw-r--r--src/corelib/io/qtextstream.h2
13 files changed, 35 insertions, 31 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 8b3dd5d82f..2ae865a534 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -777,6 +777,8 @@ QString QDir::relativeFilePath(const QString &fileName) const
result += QLatin1Char('/');
}
+ if (result.isEmpty())
+ return QLatin1String(".");
return result;
}
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index cddd70f908..85d9b0bfcb 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -80,7 +80,7 @@ QFileSelectorPrivate::QFileSelectorPrivate()
QString defaultsBasePath = "data/";
QString defaultsPath = defaultsBasePath + "defaults.conf";
QString localizedPath = defaultsBasePath
- + QString("%1/defaults.conf").arg(QLocale::system().name());
+ + QString("%1/defaults.conf").arg(QLocale().name());
if (QFile::exists(localizedPath))
defaultsPath = localizedPath;
QFile defaults(defaultsPath);
@@ -148,7 +148,7 @@ QFileSelectorPrivate::QFileSelectorPrivate()
on (list not exhaustive): android, blackberry, ios, osx, darwin, mac, linux, wince, unix,
windows. On Linux, if it can be determined, the name of the distribution too, like debian,
fedora or opensuse.
- \li locale, same as QLocale::system().name().
+ \li locale, same as QLocale().name().
\endlist
Further selectors will be added from the \c QT_FILE_SELECTORS environment variable, which
@@ -347,7 +347,7 @@ void QFileSelectorPrivate::updateSelectors()
sharedData->staticSelectors << sharedData->preloadedStatics; //Potential for static selectors from other modules
// TODO: Update on locale changed?
- sharedData->staticSelectors << QLocale::system().name();
+ sharedData->staticSelectors << QLocale().name();
sharedData->staticSelectors << platformSelectors();
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index c4fb709ddf..2c9fed530b 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -662,17 +662,11 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &
bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
{
mode_t mode = 0;
- if (permissions & QFile::ReadOwner)
+ if (permissions & (QFile::ReadOwner | QFile::ReadUser))
mode |= S_IRUSR;
- if (permissions & QFile::WriteOwner)
+ if (permissions & (QFile::WriteOwner | QFile::WriteUser))
mode |= S_IWUSR;
- if (permissions & QFile::ExeOwner)
- mode |= S_IXUSR;
- if (permissions & QFile::ReadUser)
- mode |= S_IRUSR;
- if (permissions & QFile::WriteUser)
- mode |= S_IWUSR;
- if (permissions & QFile::ExeUser)
+ if (permissions & (QFile::ExeOwner | QFile::ExeUser))
mode |= S_IXUSR;
if (permissions & QFile::ReadGroup)
mode |= S_IRGRP;
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 5cca3c323e..d62c120d7e 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1437,11 +1437,9 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per
Q_UNUSED(data);
int mode = 0;
- if (permissions & QFile::ReadOwner || permissions & QFile::ReadUser
- || permissions & QFile::ReadGroup || permissions & QFile::ReadOther)
+ if (permissions & (QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther))
mode |= _S_IREAD;
- if (permissions & QFile::WriteOwner || permissions & QFile::WriteUser
- || permissions & QFile::WriteGroup || permissions & QFile::WriteOther)
+ if (permissions & (QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther))
mode |= _S_IWRITE;
if (mode == 0) // not supported
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 3a8f7bd0a9..7fc3049f46 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -185,7 +185,7 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re
the file system monitor. Also note that your process may have
other file descriptors open in addition to the ones for files
being monitored, and these other open descriptors also count in
- the total. OS X 10.5 and up use a different backend and do not
+ the total. Mac OS X 10.5 and up use a different backend and do not
suffer from this issue.
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 039992adba..4907a20a5f 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -248,6 +248,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
// ###
files->removeAll(path);
directories->removeAll(path);
+ it.remove();
if (h.isEmpty()) {
DEBUG() << "Closing handle" << handle.handle;
@@ -260,8 +261,6 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
thread->handleForDir.remove(QFileSystemWatcherPathKey(absolutePath));
// h is now invalid
- it.remove();
-
if (thread->handleForDir.isEmpty()) {
DEBUG() << "Stopping thread " << thread;
locker.unlock();
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index d6ea2f1f2d..815c0f025b 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -56,6 +56,7 @@
# include <cstdio>
#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
# include <sys/user.h>
+# include <libutil.h>
#endif
QT_BEGIN_NAMESPACE
@@ -218,24 +219,25 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
#if defined(Q_OS_OSX)
char name[1024];
proc_name(pid, name, sizeof(name) / sizeof(char));
- return QString::fromUtf8(name);
+ return QFile::decodeName(name);
#elif defined(Q_OS_LINUX)
if (!QFile::exists(QStringLiteral("/proc/version")))
return QString();
char exePath[64];
- char buf[PATH_MAX];
- memset(buf, 0, sizeof(buf));
+ char buf[PATH_MAX + 1];
sprintf(exePath, "/proc/%lld/exe", pid);
- if (readlink(exePath, buf, sizeof(buf)) < 0) {
+ size_t len = (size_t)readlink(exePath, buf, sizeof(buf));
+ if (len >= sizeof(buf)) {
// The pid is gone. Return some invalid process name to fail the test.
return QStringLiteral("/ERROR/");
}
- return QFileInfo(QString::fromUtf8(buf)).fileName();
+ buf[len] = 0;
+ return QFileInfo(QFile::decodeName(buf)).fileName();
#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
kinfo_proc *proc = kinfo_getproc(pid);
if (!proc)
return QString();
- QString name = QString::fromUtf8(proc->ki_comm);
+ QString name = QFile::decodeName(proc->ki_comm);
free(proc);
return name;
#else
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 093cb85bfb..218e8b959c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2086,7 +2086,7 @@ QByteArray QProcess::readAllStandardError()
printed at the console, and the existing process will continue running
unaffected.
- \sa pid(), started(), waitForStarted(), setNativeArguments()
+ \sa processId(), started(), waitForStarted(), setNativeArguments()
*/
void QProcess::start(const QString &program, const QStringList &arguments, OpenMode mode)
{
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 47611d4b00..0d6ef9e60f 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -1085,6 +1085,9 @@ bool QProcessPrivate::waitForDeadChild()
exitCode = info.si_status;
crashed = info.si_code != CLD_EXITED;
+ delete deathNotifier;
+ deathNotifier = 0;
+
qt_safe_close(forkfd);
forkfd = -1; // Child is dead, don't try to kill it anymore
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp
index d63b6a2a21..337a9c7cef 100644
--- a/src/corelib/io/qstorageinfo.cpp
+++ b/src/corelib/io/qstorageinfo.cpp
@@ -186,6 +186,8 @@ QString QStorageInfo::rootPath() const
This size can be less than or equal to the free size returned by
bytesFree() function.
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesTotal(), bytesFree()
*/
qint64 QStorageInfo::bytesAvailable() const
@@ -198,6 +200,8 @@ qint64 QStorageInfo::bytesAvailable() const
quotas on the filesystem, this value can be larger than the value
returned by bytesAvailable().
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesTotal(), bytesAvailable()
*/
qint64 QStorageInfo::bytesFree() const
@@ -208,6 +212,8 @@ qint64 QStorageInfo::bytesFree() const
/*!
Returns the total volume size in bytes.
+ Returns -1 if QStorageInfo object is not valid.
+
\sa bytesFree(), bytesAvailable()
*/
qint64 QStorageInfo::bytesTotal() const
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 9e152df1ad..564321bedd 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -53,7 +53,7 @@ class QStorageInfoPrivate : public QSharedData
{
public:
inline QStorageInfoPrivate() : QSharedData(),
- bytesTotal(0), bytesFree(0), bytesAvailable(0),
+ bytesTotal(-1), bytesFree(-1), bytesAvailable(-1),
readOnly(false), ready(false), valid(false)
{}
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 47b96d708f..8ad1c2852c 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -1591,7 +1591,7 @@ QString QTextStream::readLine(qint64 maxlen)
{
QString line;
- readLine(&line, maxlen);
+ readLineInto(&line, maxlen);
return line;
}
@@ -1612,7 +1612,7 @@ QString QTextStream::readLine(qint64 maxlen)
If \a line has sufficient capacity for the data that is about to be
read, this function may not need to allocate new memory. Because of
- this, it can be faster than the other readLine() overload.
+ this, it can be faster than readLine().
Returns \c false if the stream has read to the end of the file or
an error has occurred; otherwise returns \c true. The contents in
@@ -1620,7 +1620,7 @@ QString QTextStream::readLine(qint64 maxlen)
\sa readAll(), QIODevice::readLine()
*/
-bool QTextStream::readLine(QString *line, qint64 maxlen)
+bool QTextStream::readLineInto(QString *line, qint64 maxlen)
{
Q_D(QTextStream);
// keep in sync with CHECK_VALID_STREAM
diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h
index 125502e68d..e5f429ae4d 100644
--- a/src/corelib/io/qtextstream.h
+++ b/src/corelib/io/qtextstream.h
@@ -124,7 +124,7 @@ public:
void skipWhiteSpace();
QString readLine(qint64 maxlen = 0);
- bool readLine(QString *line, qint64 maxlen = 0);
+ bool readLineInto(QString *line, qint64 maxlen = 0);
QString readAll();
QString read(qint64 maxlen);