summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfile.cpp5
-rw-r--r--src/corelib/io/qfiledevice.cpp7
-rw-r--r--src/corelib/io/qfileinfo.cpp3
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp41
-rw-r--r--src/corelib/io/qfsfileengine.cpp5
-rw-r--r--src/corelib/io/qlockfile.cpp13
-rw-r--r--src/corelib/io/qprocess.cpp15
-rw-r--r--src/corelib/io/qsettings.cpp116
-rw-r--r--src/corelib/io/qsettings_mac.cpp25
-rw-r--r--src/corelib/io/qsettings_p.h4
10 files changed, 96 insertions, 138 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 9b1bd3a411..41fae69bb2 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -923,8 +923,6 @@ bool QFile::open(OpenMode mode)
you cannot use this QFile with a QFileInfo.
\endlist
- \note For Windows CE you may not be able to call resize().
-
\sa close()
\b{Note for the Windows Platform}
@@ -992,9 +990,6 @@ bool QFile::open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
those cases, size() returns \c 0. See QIODevice::isSequential()
for more information.
- \warning For Windows CE you may not be able to call seek(), and size()
- returns \c 0.
-
\warning Since this function opens the file without specifying the file name,
you cannot use this QFile with a QFileInfo.
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index a2119b74db..20cfa5bdaf 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -255,8 +255,6 @@ bool QFileDevice::isSequential() const
If the file is not open, or there is an error, handle() returns -1.
- This function is not supported on Windows CE.
-
\sa QSocketNotifier
*/
int QFileDevice::handle() const
@@ -681,8 +679,7 @@ bool QFileDevice::setPermissions(Permissions permissions)
be written to disk. Any such modifications will be lost when the
memory is unmapped. It is unspecified whether modifications made
to the file made after the mapping is created will be visible through
- the mapped memory. This flag is not supported on Windows CE.
- This enum value was introduced in Qt 5.4.
+ the mapped memory. This enum value was introduced in Qt 5.4.
*/
/*!
@@ -700,8 +697,6 @@ bool QFileDevice::setPermissions(Permissions permissions)
Returns a pointer to the memory or 0 if there is an error.
- \note On Windows CE 5.0 the file will be closed before mapping occurs.
-
\sa unmap()
*/
uchar *QFileDevice::map(qint64 offset, qint64 size, MemoryMapFlags flags)
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 8b9efb638a..baf8cbd193 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -713,9 +713,6 @@ bool QFileInfo::exists(const QString &file)
/*!
Refreshes the information about the file, i.e. reads in information
from the file system the next time a cached property is fetched.
-
- \note On Windows CE, there might be a delay for the file system driver
- to detect changes on the file.
*/
void QFileInfo::refresh()
{
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index d3aef27296..a1d90c76f4 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -174,26 +174,27 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re
they have been renamed or removed from disk, and directories once
they have been removed from disk.
- \note On systems running a Linux kernel without inotify support,
- file systems that contain watched paths cannot be unmounted.
-
- \note Windows CE does not support directory monitoring by
- default as this depends on the file system driver installed.
-
- \note The act of monitoring files and directories for
- modifications consumes system resources. This implies there is a
- limit to the number of files and directories your process can
- monitor simultaneously. On all BSD variants, for
- example, an open file descriptor is required for each monitored
- file. Some system limits the number of open file descriptors to 256
- by default. This means that addPath() and addPaths() will fail if
- your process tries to add more than 256 files or directories to
- 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. \macos uses a different backend and does not
- suffer from this issue.
-
+ \list
+ \li \b Notes:
+ \list
+ \li On systems running a Linux kernel without inotify support,
+ file systems that contain watched paths cannot be unmounted.
+
+ \li The act of monitoring files and directories for
+ modifications consumes system resources. This implies there is a
+ limit to the number of files and directories your process can
+ monitor simultaneously. On all BSD variants, for
+ example, an open file descriptor is required for each monitored
+ file. Some system limits the number of open file descriptors to 256
+ by default. This means that addPath() and addPaths() will fail if
+ your process tries to add more than 256 files or directories to
+ 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. \macos uses a different backend and does not
+ suffer from this issue.
+ \endlist
+ \endlist
\sa QFile, QDir
*/
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 098bc49468..0b9cd0557f 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -880,9 +880,8 @@ bool QFSFileEngine::supportsExtension(Extension extension) const
/*! \fn QFileInfoList QFSFileEngine::drives()
For Windows, returns the list of drives in the file system as a list
- of QFileInfo objects. On Unix and Windows CE, only the
- root path is returned. On Windows, this function returns all drives
- (A:\, C:\, D:\, etc.).
+ of QFileInfo objects. On Unix, only the root path is returned.
+ On Windows, this function returns all drives (A:\, C:\, D:\, and so on).
For Unix, the list contains just the root path "/".
*/
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index cb61a52c04..ae3a7c6abc 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -42,7 +42,7 @@
#include "qlockfile_p.h"
#include <QtCore/qthread.h>
-#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qdeadlinetimer.h>
#include <QtCore/qdatetime.h>
QT_BEGIN_NAMESPACE
@@ -210,9 +210,7 @@ bool QLockFile::lock()
bool QLockFile::tryLock(int timeout)
{
Q_D(QLockFile);
- QElapsedTimer timer;
- if (timeout > 0)
- timer.start();
+ QDeadlineTimer timer(qMax(timeout, -1)); // QDT only takes -1 as "forever"
int sleepTime = 100;
forever {
d->lockError = d->tryLock_sys();
@@ -235,8 +233,13 @@ bool QLockFile::tryLock(int timeout)
}
break;
}
- if (timeout == 0 || (timeout > 0 && timer.hasExpired(timeout)))
+
+ int remainingTime = timer.remainingTime();
+ if (remainingTime == 0)
return false;
+ else if (uint(sleepTime) > uint(remainingTime))
+ sleepTime = remainingTime;
+
QThread::msleep(sleepTime);
if (sleepTime < 5 * 1000)
sleepTime *= 2;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index f9b3b9fb00..23a3cc1a16 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -150,10 +150,6 @@ QT_BEGIN_NAMESPACE
On Windows, the variable names are case-insensitive, but case-preserving.
QProcessEnvironment behaves accordingly.
- On Windows CE, the concept of environment does not exist. This class will
- keep the values set for compatibility with other platforms, but the values
- set will have no effect on the processes being created.
-
\sa QProcess, QProcess::systemEnvironment(), QProcess::setProcessEnvironment()
*/
@@ -502,9 +498,6 @@ void QProcessPrivate::Channel::clear()
used as an input source for QXmlReader, or for generating data to
be uploaded using QNetworkAccessManager.
- \note On Windows CE, reading and writing to a process
- is not supported.
-
When the process exits, QProcess reenters the \l NotRunning state
(the initial state), and emits finished().
@@ -750,7 +743,7 @@ void QProcessPrivate::Channel::clear()
/*!
\typedef QProcess::CreateProcessArgumentModifier
- \note This typedef is only available on desktop Windows and Windows CE.
+ \note This typedef is only available on desktop Windows.
On Windows, QProcess uses the Win32 API function \c CreateProcess to
start child processes. While QProcess provides a comfortable way to start
@@ -1784,9 +1777,6 @@ void QProcess::setEnvironment(const QStringList &environment)
using setEnvironment(). If no environment has been set, the
environment of the calling process will be used.
- \note The environment settings are ignored on Windows CE,
- as there is no concept of an environment.
-
\sa processEnvironment(), setEnvironment(), systemEnvironment()
*/
QStringList QProcess::environment() const
@@ -1820,9 +1810,6 @@ void QProcess::setProcessEnvironment(const QProcessEnvironment &environment)
setEnvironment() or setProcessEnvironment(). If no environment has
been set, the environment of the calling process will be used.
- \note The environment settings are ignored on Windows CE,
- as there is no concept of an environment.
-
\sa setProcessEnvironment(), setEnvironment(), QProcessEnvironment::isEmpty()
*/
QProcessEnvironment QProcess::processEnvironment() const
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index ffcb2e2d72..fcdc1e362b 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1355,7 +1355,6 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
{
QConfFile *confFile = confFiles[confFileNo].data();
bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty();
- bool ok;
/*
We can often optimize the read-only case, if the file on disk
@@ -1415,31 +1414,26 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
because they don't exist) are treated as empty files.
*/
if (file.isReadable() && fileInfo.size() != 0) {
+ bool ok = false;
#ifdef Q_OS_MAC
if (format == QSettings::NativeFormat) {
- ok = readPlistFile(confFile->name, &confFile->originalKeys);
+ QByteArray data = file.readAll();
+ ok = readPlistFile(data, &confFile->originalKeys);
} else
#endif
- {
- if (format <= QSettings::IniFormat) {
- QByteArray data = file.readAll();
- ok = readIniFile(data, &confFile->unparsedIniSections);
- } else {
- if (readFunc) {
- QSettings::SettingsMap tempNewKeys;
- ok = readFunc(file, tempNewKeys);
-
- if (ok) {
- QSettings::SettingsMap::const_iterator i = tempNewKeys.constBegin();
- while (i != tempNewKeys.constEnd()) {
- confFile->originalKeys.insert(QSettingsKey(i.key(),
- caseSensitivity),
- i.value());
- ++i;
- }
- }
- } else {
- ok = false;
+ if (format <= QSettings::IniFormat) {
+ QByteArray data = file.readAll();
+ ok = readIniFile(data, &confFile->unparsedIniSections);
+ } else if (readFunc) {
+ QSettings::SettingsMap tempNewKeys;
+ ok = readFunc(file, tempNewKeys);
+
+ if (ok) {
+ QSettings::SettingsMap::const_iterator i = tempNewKeys.constBegin();
+ while (i != tempNewKeys.constEnd()) {
+ confFile->originalKeys.insert(QSettingsKey(i.key(), caseSensitivity),
+ i.value());
+ ++i;
}
}
}
@@ -1457,44 +1451,42 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
so everything is under control.
*/
if (!readOnly) {
+ bool ok = false;
ensureAllSectionsParsed(confFile);
ParsedSettingsMap mergedKeys = confFile->mergedKeyMap();
-#ifdef Q_OS_MAC
- if (format == QSettings::NativeFormat) {
- ok = writePlistFile(confFile->name, mergedKeys);
- } else
-#endif
- {
#ifndef QT_BOOTSTRAPPED
- QSaveFile sf(confFile->name);
+ QSaveFile sf(confFile->name);
#else
- QFile sf(confFile->name);
+ QFile sf(confFile->name);
#endif
- if (!sf.open(QIODevice::WriteOnly)) {
- setStatus(QSettings::AccessError);
- ok = false;
- } else if (format <= QSettings::IniFormat) {
- ok = writeIniFile(sf, mergedKeys);
- } else {
- if (writeFunc) {
- QSettings::SettingsMap tempOriginalKeys;
+ if (!sf.open(QIODevice::WriteOnly)) {
+ setStatus(QSettings::AccessError);
+ return;
+ }
- ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
- while (i != mergedKeys.constEnd()) {
- tempOriginalKeys.insert(i.key(), i.value());
- ++i;
- }
- ok = writeFunc(sf, tempOriginalKeys);
- } else {
- ok = false;
- }
+#ifdef Q_OS_MAC
+ if (format == QSettings::NativeFormat) {
+ ok = writePlistFile(sf, mergedKeys);
+ } else
+#endif
+ if (format <= QSettings::IniFormat) {
+ ok = writeIniFile(sf, mergedKeys);
+ } else if (writeFunc) {
+ QSettings::SettingsMap tempOriginalKeys;
+
+ ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
+ while (i != mergedKeys.constEnd()) {
+ tempOriginalKeys.insert(i.key(), i.value());
+ ++i;
}
+ ok = writeFunc(sf, tempOriginalKeys);
+ }
+
#ifndef QT_BOOTSTRAPPED
- if (ok)
- ok = sf.commit();
+ if (ok)
+ ok = sf.commit();
#endif
- }
if (ok) {
confFile->unparsedIniSections.clear();
@@ -2235,16 +2227,20 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
On Windows, the following files are used:
\list 1
- \li \c{%APPDATA%\MySoft\Star Runner.ini}
- \li \c{%APPDATA%\MySoft.ini}
- \li \c{%COMMON_APPDATA%\MySoft\Star Runner.ini}
- \li \c{%COMMON_APPDATA%\MySoft.ini}
+ \li \c{CSIDL_APPDATA\MySoft\Star Runner.ini}
+ \li \c{CSIDL_APPDATA\MySoft.ini}
+ \li \c{CSIDL_COMMON_APPDATA\MySoft\Star Runner.ini}
+ \li \c{CSIDL_COMMON_APPDATA\MySoft.ini}
\endlist
- The \c %APPDATA% path is usually \tt{C:\\Documents and
- Settings\\\e{User Name}\\Application Data}; the \c
- %COMMON_APPDATA% path is usually \tt{C:\\Documents and
- Settings\\All Users\\Application Data}.
+ The identifiers prefixed by \c{CSIDL_} are special item ID lists to be passed
+ to the Win32 API function \c{SHGetSpecialFolderPath()} to obtain the
+ corresponding path.
+
+ \c{CSIDL_APPDATA} usually points to \tt{C:\\Users\\\e{User Name}\\AppData\\Roaming},
+ also shown by the environment variable \c{%APPDATA%}.
+
+ \c{CSIDL_COMMON_APPDATA} usually points to \tt{C:\\ProgramData}.
If the file format is IniFormat, this is "Settings/MySoft/Star Runner.ini"
in the application's home directory.
@@ -3348,8 +3344,8 @@ void QSettings::setUserIniPath(const QString &dir)
\table
\header \li Platform \li Format \li Scope \li Path
- \row \li{1,2} Windows \li{1,2} IniFormat \li UserScope \li \c %APPDATA%
- \row \li SystemScope \li \c %COMMON_APPDATA%
+ \row \li{1,2} Windows \li{1,2} IniFormat \li UserScope \li \c CSIDL_APPDATA
+ \row \li SystemScope \li \c CSIDL_COMMON_APPDATA
\row \li{1,2} Unix \li{1,2} NativeFormat, IniFormat \li UserScope \li \c $HOME/.config
\row \li SystemScope \li \c /etc/xdg
\row \li{1,2} Qt for Embedded Linux \li{1,2} NativeFormat, IniFormat \li UserScope \li \c $HOME/Settings
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 7f857a77a4..bc397055ff 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -613,24 +613,11 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format,
}
}
-static QCFType<CFURLRef> urlFromFileName(const QString &fileName)
+bool QConfFileSettingsPrivate::readPlistFile(const QByteArray &data, ParsedSettingsMap *map) const
{
- return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, QCFString(fileName),
- kCFURLPOSIXPathStyle, false);
-}
-
-bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSettingsMap *map) const
-{
- QCFType<CFDataRef> resource;
- SInt32 code;
- if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, urlFromFileName(fileName),
- &resource, 0, 0, &code))
- return false;
-
- QCFString errorStr;
+ QCFType<CFDataRef> cfData = data.toRawCFData();
QCFType<CFPropertyListRef> propertyList =
- CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable,
- &errorStr);
+ CFPropertyListCreateWithData(kCFAllocatorDefault, cfData, kCFPropertyListImmutable, Q_NULLPTR, Q_NULLPTR);
if (!propertyList)
return true;
@@ -651,8 +638,7 @@ bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSett
return true;
}
-bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
- const ParsedSettingsMap &map) const
+bool QConfFileSettingsPrivate::writePlistFile(QIODevice &file, const ParsedSettingsMap &map) const
{
QVarLengthArray<QCFType<CFStringRef> > cfkeys(map.size());
QVarLengthArray<QCFType<CFPropertyListRef> > cfvalues(map.size());
@@ -675,8 +661,7 @@ bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
QCFType<CFDataRef> xmlData = CFPropertyListCreateData(
kCFAllocatorDefault, propertyList, kCFPropertyListXMLFormat_v1_0, 0, 0);
- SInt32 code;
- return CFURLWriteDataAndPropertiesToResource(urlFromFileName(fileName), xmlData, 0, &code);
+ return file.write(QByteArray::fromRawCFData(xmlData)) == CFDataGetLength(xmlData);
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index 9d7b667514..e6d3413bab 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -296,8 +296,8 @@ private:
void syncConfFile(int confFileNo);
bool writeIniFile(QIODevice &device, const ParsedSettingsMap &map);
#ifdef Q_OS_MAC
- bool readPlistFile(const QString &fileName, ParsedSettingsMap *map) const;
- bool writePlistFile(const QString &fileName, const ParsedSettingsMap &map) const;
+ bool readPlistFile(const QByteArray &data, ParsedSettingsMap *map) const;
+ bool writePlistFile(QIODevice &file, const ParsedSettingsMap &map) const;
#endif
void ensureAllSectionsParsed(QConfFile *confFile) const;
void ensureSectionParsed(QConfFile *confFile, const QSettingsKey &key) const;