Convert improper uses of qt_error_string() to QSystemError::stdString()
On Windows, qt_error_string() returns the string corresponding to the Win32 API, not an errno. Replace those uses for a function that works for errno values. Change-Id: I1eba2b016de74620bfc8fffd14ccce6162bafdca Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f3205a4949
commit
bf410ed529
@ -268,7 +268,7 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh)
|
||||
|
||||
if (ret != 0) {
|
||||
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
|
||||
qt_error_string(int(errno)));
|
||||
QSystemError::stdString());
|
||||
|
||||
this->openMode = QIODevice::NotOpen;
|
||||
this->fh = 0;
|
||||
@ -332,7 +332,7 @@ bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd)
|
||||
|
||||
if (ret == -1) {
|
||||
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
|
||||
qt_error_string(int(errno)));
|
||||
QSystemError::stdString());
|
||||
|
||||
this->openMode = QIODevice::NotOpen;
|
||||
this->fd = -1;
|
||||
@ -391,7 +391,7 @@ bool QFSFileEnginePrivate::closeFdFh()
|
||||
if (!flushed || !closed) {
|
||||
if (flushed) {
|
||||
// If not flushed, we want the flush error to fall through.
|
||||
q->setError(QFile::UnspecifiedError, qt_error_string(errno));
|
||||
q->setError(QFile::UnspecifiedError, QSystemError::stdString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -443,7 +443,7 @@ bool QFSFileEnginePrivate::flushFh()
|
||||
|
||||
if (ret != 0) {
|
||||
q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError,
|
||||
qt_error_string(errno));
|
||||
QSystemError::stdString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -539,14 +539,14 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos)
|
||||
} while (ret != 0 && errno == EINTR);
|
||||
|
||||
if (ret != 0) {
|
||||
q->setError(QFile::ReadError, qt_error_string(int(errno)));
|
||||
q->setError(QFile::ReadError, QSystemError::stdString());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Unbuffered stdio mode.
|
||||
if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) {
|
||||
qWarning("QFile::at: Cannot set file position %lld", pos);
|
||||
q->setError(QFile::PositionError, qt_error_string(errno));
|
||||
q->setError(QFile::PositionError, QSystemError::stdString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -588,7 +588,7 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
|
||||
Q_Q(QFSFileEngine);
|
||||
|
||||
if (len < 0 || len != qint64(size_t(len))) {
|
||||
q->setError(QFile::ReadError, qt_error_string(EINVAL));
|
||||
q->setError(QFile::ReadError, QSystemError::stdString(EINVAL));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -634,7 +634,7 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
|
||||
|
||||
if (!eof && readBytes == 0) {
|
||||
readBytes = -1;
|
||||
q->setError(QFile::ReadError, qt_error_string(errno));
|
||||
q->setError(QFile::ReadError, QSystemError::stdString());
|
||||
}
|
||||
|
||||
return readBytes;
|
||||
@ -680,7 +680,7 @@ qint64 QFSFileEnginePrivate::readLineFdFh(char *data, qint64 maxlen)
|
||||
// solves this.
|
||||
if (!fgets(data, int(maxlen + 1), fh)) {
|
||||
if (!feof(fh))
|
||||
q->setError(QFile::ReadError, qt_error_string(int(errno)));
|
||||
q->setError(QFile::ReadError, QSystemError::stdString());
|
||||
return -1; // error
|
||||
}
|
||||
|
||||
@ -719,7 +719,7 @@ qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len)
|
||||
Q_Q(QFSFileEngine);
|
||||
|
||||
if (len < 0 || len != qint64(size_t(len))) {
|
||||
q->setError(QFile::WriteError, qt_error_string(EINVAL));
|
||||
q->setError(QFile::WriteError, QSystemError::stdString(EINVAL));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -756,7 +756,7 @@ qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len)
|
||||
|
||||
if (len && writtenBytes == 0) {
|
||||
writtenBytes = -1;
|
||||
q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno));
|
||||
q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, QSystemError::stdString());
|
||||
} else {
|
||||
// reset the cached size, if any
|
||||
metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
|
||||
|
@ -252,7 +252,7 @@ qint64 QFSFileEnginePrivate::nativeSize() const
|
||||
filled = doStat(QFileSystemMetaData::SizeAttribute);
|
||||
|
||||
if (!filled) {
|
||||
thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
|
||||
thatQ->setError(QFile::UnspecifiedError, QSystemError::stdString());
|
||||
return 0;
|
||||
}
|
||||
return metaData.size();
|
||||
@ -319,7 +319,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 maxlen)
|
||||
if (fh || fd != -1) {
|
||||
// stdio / stdlib mode.
|
||||
if (fh && nativeIsSequential() && feof(fh)) {
|
||||
q->setError(QFile::ReadError, qt_error_string(int(errno)));
|
||||
q->setError(QFile::ReadError, QSystemError::stdString());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <qshareddata.h>
|
||||
#include <qplatformdefs.h>
|
||||
#include "private/qabstractfileengine_p.h"
|
||||
#include "private/qsystemerror_p.h"
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
# include "private/qcore_unix_p.h"
|
||||
@ -1284,7 +1285,7 @@ bool QResourceFileEngine::open(QIODevice::OpenMode flags)
|
||||
return false;
|
||||
d->uncompress();
|
||||
if (!d->resource.isValid()) {
|
||||
d->errorString = qt_error_string(ENOENT);
|
||||
d->errorString = QSystemError::stdString(ENOENT);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <qmutex.h>
|
||||
#include <qmap.h>
|
||||
#include <private/qcoreapplication_p.h>
|
||||
#include <private/qsystemerror_p.h>
|
||||
#ifdef Q_OS_MAC
|
||||
# include <private/qcore_mac_p.h>
|
||||
#endif
|
||||
@ -237,7 +238,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
|
||||
lib->errorString = file.errorString();
|
||||
if (qt_debug_component()) {
|
||||
qWarning("%s: %s", (const char*) QFile::encodeName(library),
|
||||
qPrintable(qt_error_string(errno)));
|
||||
qPrintable(QSystemError::stdString()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user