diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-09 01:17:44 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-29 18:19:52 +0300 |
commit | fe4f977a2df9c99030e7841387fd65f033f99721 (patch) | |
tree | e5d0f32df3f4373de4da432f49077bf441e12a23 /src/corelib/io/qstorageinfo_unix.cpp | |
parent | 961ff0cc8a7408f59b2d0f9adfa980fd89bd3274 (diff) |
QStorageInfo: use the same code on Linux and Android
/proc/self/mountinfo is available on Android too AFAIK (it's available
on an old Android 6.0 phone I have).
Change-Id: Ia4b04a143b362c7a18773716a90897ce4c5fc5f0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/corelib/io/qstorageinfo_unix.cpp')
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 76 |
1 files changed, 3 insertions, 73 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index cdf5315dd1..47c414d733 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -25,7 +25,6 @@ #elif defined(Q_OS_ANDROID) # include <sys/mount.h> # include <sys/vfs.h> -# include <mntent.h> #elif defined(Q_OS_LINUX) # include <sys/statvfs.h> #elif defined(Q_OS_HURD) @@ -112,12 +111,6 @@ private: #elif defined(Q_OS_SOLARIS) FILE *fp; mnttab mnt; -#elif defined(Q_OS_ANDROID) - QFile file; - QByteArray m_rootPath; - QByteArray m_fileSystemType; - QByteArray m_device; - QByteArray m_options; #elif defined(Q_OS_HURD) FILE *fp; QByteArray buffer; @@ -224,66 +217,6 @@ inline QByteArray QStorageIterator::subvolume() const { return QByteArray(); } -#elif defined(Q_OS_ANDROID) - -inline QStorageIterator::QStorageIterator() -{ - file.setFileName(QString::fromUtf8(_PATH_MOUNTED)); - file.open(QIODevice::ReadOnly | QIODevice::Text); -} - -inline QStorageIterator::~QStorageIterator() -{ -} - -inline bool QStorageIterator::isValid() const -{ - return file.isOpen(); -} - -inline bool QStorageIterator::next() -{ - QList<QByteArray> data; - // If file is virtual, file.readLine() may succeed even when file.atEnd(). - do { - const QByteArray line = file.readLine(); - if (line.isEmpty() && file.atEnd()) - return false; - data = line.split(' '); - } while (data.count() < 4); - - m_device = data.at(0); - m_rootPath = data.at(1); - m_fileSystemType = data.at(2); - m_options = data.at(3); - - return true; -} - -inline QString QStorageIterator::rootPath() const -{ - return QFile::decodeName(m_rootPath); -} - -inline QByteArray QStorageIterator::fileSystemType() const -{ - return m_fileSystemType; -} - -inline QByteArray QStorageIterator::device() const -{ - return m_device; -} - -inline QByteArray QStorageIterator::options() const -{ - return m_options; -} - -inline QByteArray QStorageIterator::subvolume() const -{ - return QByteArray(); -} #elif defined(Q_OS_HURD) @@ -553,8 +486,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo() } } -#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) - +#if defined(Q_OS_LINUX) static std::vector<MountInfo> parseMountInfo(FilterMountInfo filter = FilterMountInfo::All) { QFile file(u"/proc/self/mountinfo"_s); @@ -614,9 +546,7 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() } return volumes; } - -#else // defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) - +#else // defined(Q_OS_LINUX) void QStorageInfoPrivate::initRootPath() { rootPath = QFileInfo(rootPath).canonicalFilePath(); @@ -672,7 +602,7 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() return volumes; } -#endif // defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) +#endif // defined(Q_OS_LINUX) QStorageInfo QStorageInfoPrivate::root() { |