Replace a few hardcoded paths with defaults from paths.h
This removes at least one special-case we had to have, in Android's lack of /etc/mnttab. Bionic's _PATH_MOUNTED is already /proc/mounts. Change-Id: I9407dcf22de6407c83b5fffd14fedc638586d0f9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
f95d64d075
commit
b12db22fcf
@ -63,6 +63,9 @@
|
||||
#if QT_CONFIG(slog2)
|
||||
#include <slog2.h>
|
||||
#endif
|
||||
#if QT_HAS_INCLUDE(<paths.h>)
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <android/log.h>
|
||||
@ -215,8 +218,11 @@ static bool willLogToConsole()
|
||||
# ifdef Q_OS_WIN
|
||||
return GetConsoleWindow();
|
||||
# elif defined(Q_OS_UNIX)
|
||||
# ifndef _PATH_TTY
|
||||
# define _PATH_TTY "/dev/tty"
|
||||
# endif
|
||||
// if /dev/tty exists, we can only open it if we have a controlling TTY
|
||||
int devtty = qt_safe_open("/dev/tty", O_RDONLY);
|
||||
int devtty = qt_safe_open(_PATH_TTY, O_RDONLY);
|
||||
if (devtty == -1 && (errno == ENOENT || errno == EPERM || errno == ENXIO)) {
|
||||
// no /dev/tty, fall back to isatty on stderr
|
||||
return isatty(STDERR_FILENO);
|
||||
|
@ -55,6 +55,13 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if QT_HAS_INCLUDE(<paths.h>)
|
||||
# include <paths.h>
|
||||
#endif
|
||||
#ifndef _PATH_TMP // from <paths.h>
|
||||
# define _PATH_TMP "/tmp"
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
# include <QtCore/private/qcore_mac_p.h>
|
||||
# include <CoreFoundation/CFBundle.h>
|
||||
@ -1507,14 +1514,13 @@ QString QFileSystemEngine::tempPath()
|
||||
#else
|
||||
QString temp = QFile::decodeName(qgetenv("TMPDIR"));
|
||||
if (temp.isEmpty()) {
|
||||
if (false) {
|
||||
#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
|
||||
if (NSString *nsPath = NSTemporaryDirectory()) {
|
||||
} else if (NSString *nsPath = NSTemporaryDirectory()) {
|
||||
temp = QString::fromCFString((CFStringRef)nsPath);
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
temp = QLatin1String("/tmp");
|
||||
} else {
|
||||
temp = QLatin1String(_PATH_TMP);
|
||||
}
|
||||
}
|
||||
return QDir::cleanPath(temp);
|
||||
|
@ -99,6 +99,10 @@ QT_END_NAMESPACE
|
||||
#include <private/qcore_unix_p.h>
|
||||
#endif
|
||||
|
||||
#if QT_HAS_INCLUDE(<paths.h>)
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
@ -2638,6 +2642,8 @@ QString QProcess::nullDevice()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return QStringLiteral("\\\\.\\NUL");
|
||||
#elif defined(_PATH_DEVNULL)
|
||||
return QStringLiteral(_PATH_DEVNULL);
|
||||
#else
|
||||
return QStringLiteral("/dev/null");
|
||||
#endif
|
||||
|
@ -107,6 +107,13 @@
|
||||
# endif // QT_LARGEFILE_SUPPORT
|
||||
#endif // Q_OS_BSD4
|
||||
|
||||
#if QT_HAS_INCLUDE(<paths.h>)
|
||||
# include <paths.h>
|
||||
#endif
|
||||
#ifndef _PATH_MOUNTED
|
||||
# define _PATH_MOUNTED "/etc/mnttab"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStorageIterator
|
||||
@ -241,11 +248,9 @@ inline QByteArray QStorageIterator::options() const
|
||||
|
||||
#elif defined(Q_OS_SOLARIS)
|
||||
|
||||
static const char pathMounted[] = "/etc/mnttab";
|
||||
|
||||
inline QStorageIterator::QStorageIterator()
|
||||
{
|
||||
const int fd = qt_safe_open(pathMounted, O_RDONLY);
|
||||
const int fd = qt_safe_open(_PATH_MOUNTED, O_RDONLY);
|
||||
fp = ::fdopen(fd, "r");
|
||||
}
|
||||
|
||||
@ -282,11 +287,9 @@ inline QByteArray QStorageIterator::device() const
|
||||
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
|
||||
static const QLatin1String pathMounted("/proc/mounts");
|
||||
|
||||
inline QStorageIterator::QStorageIterator()
|
||||
{
|
||||
file.setFileName(pathMounted);
|
||||
file.setFileName(_PATH_MOUNTED);
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
}
|
||||
|
||||
@ -339,14 +342,13 @@ inline QByteArray QStorageIterator::options() const
|
||||
|
||||
#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
|
||||
|
||||
static const char pathMounted[] = "/etc/mtab";
|
||||
static const int bufferSize = 1024; // 2 paths (mount point+device) and metainfo;
|
||||
// should be enough
|
||||
|
||||
inline QStorageIterator::QStorageIterator() :
|
||||
buffer(QByteArray(bufferSize, 0))
|
||||
{
|
||||
fp = ::setmntent(pathMounted, "r");
|
||||
fp = ::setmntent(_PATH_MOUNTED, "r");
|
||||
}
|
||||
|
||||
inline QStorageIterator::~QStorageIterator()
|
||||
|
Loading…
Reference in New Issue
Block a user