QDir::tempPath - use NSTemporaryDirectory on Darwin
Instead of hardcoded "/tmp". Task-number: QTBUG-57165 Change-Id: I9d3ae157c22ce131281b8279149eea87a26244e8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
53edaf0fb7
commit
e2b856d562
@ -59,6 +59,13 @@
|
||||
#include <MobileCoreServices/MobileCoreServices.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_DARWIN)
|
||||
// We cannot include <Foundation/Foundation.h> (it's an Objective-C header), but
|
||||
// we need these declarations:
|
||||
Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
|
||||
extern "C" NSString *NSTemporaryDirectory();
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(Q_OS_DARWIN)
|
||||
@ -706,8 +713,17 @@ QString QFileSystemEngine::tempPath()
|
||||
return QDir::cleanPath(temp);
|
||||
#else
|
||||
QString temp = QFile::decodeName(qgetenv("TMPDIR"));
|
||||
if (temp.isEmpty())
|
||||
temp = QLatin1String("/tmp");
|
||||
if (temp.isEmpty()) {
|
||||
#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
|
||||
if (NSString *nsPath = NSTemporaryDirectory()) {
|
||||
temp = QString::fromCFString((CFStringRef)nsPath);
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
temp = QLatin1String("/tmp");
|
||||
}
|
||||
}
|
||||
return QDir::cleanPath(temp);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user