Qt 4.8
Functions
qlibrary_win.cpp File Reference
#include "qplatformdefs.h"
#include "qlibrary_p.h"
#include "qfile.h"
#include "qdir.h"
#include "qfileinfo.h"
#include <private/qfilesystementry_p.h>
#include "qt_windows.h"

Go to the source code of this file.

Functions

QString qt_error_string (int code)
 

Function Documentation

◆ qt_error_string()

QString qt_error_string ( int  code)

Definition at line 2600 of file qglobal.cpp.

Referenced by QLocalServerPrivate::addListener(), QFSFileEnginePrivate::closeFdFh(), QProcessPrivate::execChild(), QFSFileEnginePrivate::flushFh(), QFSFileEnginePrivate::longFileName(), QFSFileEnginePrivate::map(), QFSFileEnginePrivate::nativeOpen(), QFSFileEnginePrivate::nativeRead(), QFSFileEnginePrivate::openFd(), QFSFileEnginePrivate::openFh(), QProcessPrivate::processStarted(), qErrnoWarning(), qt_create_commandline(), qt_create_pipe(), qt_message(), qt_parse_pattern(), QNativeSocketEngine::read(), QFSFileEnginePrivate::readFdFh(), QFSFileEnginePrivate::readLineFdFh(), report_error(), QFSFileEnginePrivate::seekFdFh(), QFilePrivate::setError(), QFSFileEngine::setSize(), QThread::start(), QProcessPrivate::startProcess(), QThread::terminate(), QFSFileEnginePrivate::unmap(), QFSFileEnginePrivate::writeFdFh(), and QProcessPrivate::writeToStdin().

2601 {
2602  const char *s = 0;
2603  QString ret;
2604  if (errorCode == -1) {
2605 #if defined(Q_OS_WIN)
2606  errorCode = GetLastError();
2607 #else
2608  errorCode = errno;
2609 #endif
2610  }
2611  switch (errorCode) {
2612  case 0:
2613  break;
2614  case EACCES:
2615  s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied");
2616  break;
2617  case EMFILE:
2618  s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files");
2619  break;
2620  case ENOENT:
2621  s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory");
2622  break;
2623  case ENOSPC:
2624  s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
2625  break;
2626  default: {
2627 #ifdef Q_OS_WIN
2628  wchar_t *string = 0;
2629  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
2630  NULL,
2631  errorCode,
2632  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
2633  (LPWSTR)&string,
2634  0,
2635  NULL);
2636  ret = QString::fromWCharArray(string);
2637  LocalFree((HLOCAL)string);
2638 
2639  if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
2640  ret = QString::fromLatin1("The specified module could not be found.");
2641 #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
2642  QByteArray buf(1024, '\0');
2643  ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
2644 #else
2645  ret = QString::fromLocal8Bit(strerror(errorCode));
2646 #endif
2647  break; }
2648  }
2649  if (s)
2650  // ######## this breaks moc build currently
2651 // ret = QCoreApplication::translate("QIODevice", s);
2652  ret = QString::fromLatin1(s);
2653  return ret.trimmed();
2654 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int errno