QFileSystemEngine: optimize from...(qgetenv())
Use the QByteArray overload, which no longer calls strlen(), but uses the QByteArray length. No danger of embedded NULs, because environment variables cannot contain NULs. Change-Id: I33fe479adfce2624c7042608e8e0a5c5b54a85db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
be6b27aaa1
commit
28dcb7101e
@ -1218,7 +1218,7 @@ QString QFileSystemEngine::rootPath()
|
||||
ret = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr)));
|
||||
|
||||
#else
|
||||
QString ret = QString::fromLatin1(qgetenv("SystemDrive").constData());
|
||||
QString ret = QString::fromLatin1(qgetenv("SystemDrive"));
|
||||
if (ret.isEmpty())
|
||||
ret = QLatin1String("c:");
|
||||
ret.append(QLatin1Char('/'));
|
||||
@ -1253,12 +1253,12 @@ QString QFileSystemEngine::homePath()
|
||||
}
|
||||
#endif
|
||||
if (ret.isEmpty() || !QFile::exists(ret)) {
|
||||
ret = QString::fromLocal8Bit(qgetenv("USERPROFILE").constData());
|
||||
ret = QString::fromLocal8Bit(qgetenv("USERPROFILE"));
|
||||
if (ret.isEmpty() || !QFile::exists(ret)) {
|
||||
ret = QString::fromLocal8Bit(qgetenv("HOMEDRIVE").constData())
|
||||
+ QString::fromLocal8Bit(qgetenv("HOMEPATH").constData());
|
||||
ret = QString::fromLocal8Bit(qgetenv("HOMEDRIVE"))
|
||||
+ QString::fromLocal8Bit(qgetenv("HOMEPATH"));
|
||||
if (ret.isEmpty() || !QFile::exists(ret)) {
|
||||
ret = QString::fromLocal8Bit(qgetenv("HOME").constData());
|
||||
ret = QString::fromLocal8Bit(qgetenv("HOME"));
|
||||
if (ret.isEmpty() || !QFile::exists(ret)) {
|
||||
#if defined(Q_OS_WINCE)
|
||||
ret = QLatin1String("\\My Documents");
|
||||
|
Loading…
Reference in New Issue
Block a user