From b12db22fcf3ebd3dc5a7143a61745d408ab833aa Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 9 Dec 2017 22:54:04 -0800 Subject: 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 --- src/corelib/io/qstorageinfo_unix.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/corelib/io/qstorageinfo_unix.cpp') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 1fc32e0f2d..c2d31e7677 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -107,6 +107,13 @@ # endif // QT_LARGEFILE_SUPPORT #endif // Q_OS_BSD4 +#if QT_HAS_INCLUDE() +# include +#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() -- cgit v1.2.3