ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04856
[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-remove-qstorageinfo-sources into lp:ubuntu-docviewer-app/reboot
Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-remove-qstorageinfo-sources into lp:ubuntu-docviewer-app/reboot.
Commit message:
Removed QStorageInfo sources. Build depends on Qt 5.4
Requested reviews:
Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/reboot-remove-qstorageinfo-sources/+merge/270569
Removed QStorageInfo sources. Build depends on Qt 5.4
--
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-remove-qstorageinfo-sources into lp:ubuntu-docviewer-app/reboot.
=== modified file 'debian/control'
--- debian/control 2015-02-23 12:49:52 +0000
+++ debian/control 2015-09-09 17:26:50 +0000
@@ -11,7 +11,7 @@
pkg-kde-tools,
python3-all,
qt5-default,
- qtbase5-dev,
+ qtbase5-dev (>= 5.4.0),
qtchooser,
qtdeclarative5-dev,
qtdeclarative5-dev-tools,
=== modified file 'src/plugin/file-qml-plugin/CMakeLists.txt'
--- src/plugin/file-qml-plugin/CMakeLists.txt 2015-05-13 14:22:36 +0000
+++ src/plugin/file-qml-plugin/CMakeLists.txt 2015-09-09 17:26:50 +0000
@@ -3,12 +3,10 @@
#add the sources to compile
set(fileqmlplugin_SRCS
- backend.cpp
- documentmodel.cpp
- fswatcher.cpp
- docviewerfile.cpp
- qstorageinfo.cpp
- qstorageinfo_unix.cpp
+ backend.cpp
+ documentmodel.cpp
+ fswatcher.cpp
+ docviewerfile.cpp
)
add_library(fileqmlplugin MODULE
=== modified file 'src/plugin/file-qml-plugin/documentmodel.cpp'
--- src/plugin/file-qml-plugin/documentmodel.cpp 2015-08-04 16:01:37 +0000
+++ src/plugin/file-qml-plugin/documentmodel.cpp 2015-09-09 17:26:50 +0000
@@ -17,12 +17,11 @@
#include "documentmodel.h"
#include "fswatcher.h"
-#include "qstorageinfo.h"
#include <QStandardPaths>
#include <QDir>
#include <QFileInfo>
-
+#include <QStorageInfo>
#include <QMimeDatabase>
#include <QDateTime>
=== removed file 'src/plugin/file-qml-plugin/qstorageinfo.cpp'
--- src/plugin/file-qml-plugin/qstorageinfo.cpp 2015-05-13 14:22:36 +0000
+++ src/plugin/file-qml-plugin/qstorageinfo.cpp 1970-01-01 00:00:00 +0000
@@ -1,378 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@xxxxxxxxx>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 3.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#include "qstorageinfo.h"
-#include "qstorageinfo_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QStorageInfo
- \inmodule QtCore
- \since 5.4
- \brief Provides information about currently mounted storage and drives.
-
- \ingroup io
- \ingroup shared
-
- Allows retrieving information about the volume's space, its mount point,
- label, and filesystem name.
-
- You can create an instance of QStorageInfo by passing the path to the
- volume's mount point as a constructor parameter, or you can set it using
- the setPath() method. The static mountedVolumes() method can be used to get the
- list of all mounted filesystems.
-
- QStorageInfo always caches the retrieved information, but you can call
- refresh() to invalidate the cache.
-
- The following example retrieves the most common information about the root
- volume of the system, and prints information about it.
-
- \snippet code/src_corelib_io_qstorageinfo.cpp 2
-*/
-
-/*!
- Constructs an empty QStorageInfo object.
-
- Objects created with the default constructor will be invalid and therefore
- not ready for use.
-
- \sa setPath(), isReady(), isValid()
-*/
-QStorageInfo::QStorageInfo()
- : d(new QStorageInfoPrivate)
-{
-}
-
-/*!
- Constructs a new QStorageInfo object that gives information about the volume
- mounted at \a path.
-
- If you pass a directory or file, the QStorageInfo object will refer to the
- volume where this directory or file is located.
- You can check if the created object is correct using the isValid() method.
-
- The following example shows how to get the volume on which the application is
- located. It is recommended to always check that the volume is ready and valid.
-
- \snippet code/src_corelib_io_qstorageinfo.cpp 0
-
- \sa setPath()
-*/
-QStorageInfo::QStorageInfo(const QString &path)
- : d(new QStorageInfoPrivate)
-{
- setPath(path);
-}
-
-/*!
- Constructs a new QStorageInfo object that gives information about the volume
- containing the \a dir folder.
-*/
-QStorageInfo::QStorageInfo(const QDir &dir)
- : d(new QStorageInfoPrivate)
-{
- setPath(dir.absolutePath());
-}
-
-/*!
- Constructs a new QStorageInfo object that is a copy of the \a other QStorageInfo object.
-*/
-QStorageInfo::QStorageInfo(const QStorageInfo &other)
- : d(other.d)
-{
-}
-
-/*!
- Destroys the QStorageInfo object and frees its resources.
-*/
-QStorageInfo::~QStorageInfo()
-{
-}
-
-/*!
- Makes a copy of the QStorageInfo object \a other and assigns it to this QStorageInfo object.
-*/
-QStorageInfo &QStorageInfo::operator=(const QStorageInfo &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- \fn QStorageInfo &QStorageInfo::operator=(QStorageInfo &&other)
-
- Assigns \a other to this QStorageInfo instance.
-*/
-
-/*!
- \fn void QStorageInfo::swap(QStorageInfo &other)
-
- Swaps this volume info with \a other. This function is very fast and
- never fails.
-*/
-
-/*!
- Sets this QStorageInfo object to the filesystem mounted where \a path is located.
-
- \a path can either be a root path of the filesystem, a directory, or a file
- within that filesystem.
-
- \sa rootPath()
-*/
-void QStorageInfo::setPath(const QString &path)
-{
- if (d->rootPath == path)
- return;
- d.detach();
- d->rootPath = path;
- d->doStat();
-}
-
-/*!
- Returns the mount point of the filesystem this QStorageInfo object
- represents.
-
- On Windows, it returns the volume letter in case the volume is not mounted to
- a directory.
-
- Note that the value returned by rootPath() is the real mount point of a
- volume, and may not be equal to the value passed to the constructor or setPath()
- method. For example, if you have only the root volume in the system, and
- pass '/directory' to setPath(), then this method will return '/'.
-
- \sa setPath(), device()
-*/
-QString QStorageInfo::rootPath() const
-{
- return d->rootPath;
-}
-
-/*!
- Returns the size (in bytes) available for the current user. It returns
- the total size available if the user is the root user or a system administrator.
-
- This size can be less than or equal to the free size returned by
- bytesFree() function.
-
- \sa bytesTotal(), bytesFree()
-*/
-qint64 QStorageInfo::bytesAvailable() const
-{
- return d->bytesAvailable;
-}
-
-/*!
- Returns the number of free bytes in a volume. Note that if there are
- quotas on the filesystem, this value can be larger than the value
- returned by bytesAvailable().
-
- \sa bytesTotal(), bytesAvailable()
-*/
-qint64 QStorageInfo::bytesFree() const
-{
- return d->bytesFree;
-}
-
-/*!
- Returns the total volume size in bytes.
-
- \sa bytesFree(), bytesAvailable()
-*/
-qint64 QStorageInfo::bytesTotal() const
-{
- return d->bytesTotal;
-}
-
-/*!
- Returns the type name of the filesystem.
-
- This is a platform-dependent function, and filesystem names can vary
- between different operating systems. For example, on Windows filesystems
- they can be named \c NTFS, and on Linux they can be named \c ntfs-3g or \c fuseblk.
-
- \sa name()
-*/
-QByteArray QStorageInfo::fileSystemType() const
-{
- return d->fileSystemType;
-}
-
-/*!
- Returns the device for this volume.
-
- For example, on Unix filesystems (including OS X), this returns the
- devpath like \c /dev/sda0 for local storages. On Windows, it returns the UNC
- path starting with \c \\\\?\\ for local storages (in other words, the volume GUID).
-
- \sa rootPath()
-*/
-QByteArray QStorageInfo::device() const
-{
- return d->device;
-}
-
-/*!
- Returns the human-readable name of a filesystem, usually called \c label.
-
- Not all filesystems support this feature. In this case, the value returned by
- this method could be empty. An empty string is returned if the file system
- does not support labels, or if no label is set.
-
- On Linux, retrieving the volume's label requires \c udev to be present in the
- system.
-
- \sa fileSystemType()
-*/
-QString QStorageInfo::name() const
-{
- return d->name;
-}
-
-/*!
- Returns the volume's name, if available, or the root path if not.
-*/
-QString QStorageInfo::displayName() const
-{
- if (!d->name.isEmpty())
- return d->name;
- return d->rootPath;
-}
-
-/*!
- \fn bool QStorageInfo::isRoot() const
-
- Returns true if this QStorageInfo represents the system root volume; false
- otherwise.
-
- On Unix filesystems, the root volume is a volume mounted on \c /. On Windows,
- the root volume is the volume where the OS is installed.
-
- \sa root()
-*/
-
-/*!
- Returns true if the current filesystem is protected from writing; false
- otherwise.
-*/
-bool QStorageInfo::isReadOnly() const
-{
- return d->readOnly;
-}
-
-/*!
- Returns true if the current filesystem is ready to work; false otherwise. For
- example, false is returned if the CD volume is not inserted.
-
- Note that fileSystemType(), name(), bytesTotal(), bytesFree(), and
- bytesAvailable() will return invalid data until the volume is ready.
-
- \sa isValid()
-*/
-bool QStorageInfo::isReady() const
-{
- return d->ready;
-}
-
-/*!
- Returns true if the QStorageInfo specified by rootPath exists and is mounted
- correctly.
-
- \sa isReady()
-*/
-bool QStorageInfo::isValid() const
-{
- return d->valid;
-}
-
-/*!
- Resets QStorageInfo's internal cache.
-
- QStorageInfo caches information about storage to speed up performance.
- QStorageInfo retrieves information during object construction and/or when calling
- the setPath() method. You have to manually reset the cache by calling this
- function to update storage information.
-*/
-void QStorageInfo::refresh()
-{
- d.detach();
- d->doStat();
-}
-
-/*!
- Returns the list of QStorageInfo objects that corresponds to the list of currently
- mounted filesystems.
-
- On Windows, this returns the drives visible in the \gui{My Computer} folder. On Unix
- operating systems, it returns the list of all mounted filesystems (except for
- pseudo filesystems).
-
- Returns all currently mounted filesystems by default.
-
- The example shows how to retrieve all available filesystems, skipping read-only ones.
-
- \snippet code/src_corelib_io_qstorageinfo.cpp 1
-
- \sa root()
-*/
-QList<QStorageInfo> QStorageInfo::mountedVolumes()
-{
- return QStorageInfoPrivate::mountedVolumes();
-}
-
-Q_GLOBAL_STATIC_WITH_ARGS(QStorageInfo, getRoot, (QStorageInfoPrivate::root()))
-
-/*!
- Returns a QStorageInfo object that represents the system root volume.
-
- On Unix systems this call returns the root ('/') volume; in Windows the volume where
- the operating system is installed.
-
- \sa isRoot()
-*/
-QStorageInfo QStorageInfo::root()
-{
- return *getRoot();
-}
-
-/*!
- \fn inline bool operator==(const QStorageInfo &first, const QStorageInfo &second)
-
- \relates QStorageInfo
-
- Returns true if the \a first QStorageInfo object refers to the same drive or volume
- as the \a second; otherwise it returns false.
-
- Note that the result of comparing two invalid QStorageInfo objects is always
- positive.
-*/
-
-/*!
- \fn inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second)
-
- \relates QStorageInfo
-
- Returns true if the \a first QStorageInfo object refers to a different drive or
- volume than the \a second; otherwise returns false.
-*/
-
-QT_END_NAMESPACE
=== removed file 'src/plugin/file-qml-plugin/qstorageinfo.h'
--- src/plugin/file-qml-plugin/qstorageinfo.h 2015-05-13 14:22:36 +0000
+++ src/plugin/file-qml-plugin/qstorageinfo.h 1970-01-01 00:00:00 +0000
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@xxxxxxxxx>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 3.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef QSTORAGEINFO_H
-#define QSTORAGEINFO_H
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qmetatype.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qshareddata.h>
-
-QT_BEGIN_NAMESPACE
-
-class QStorageInfoPrivate;
-class Q_CORE_EXPORT QStorageInfo
-{
-public:
- QStorageInfo();
- explicit QStorageInfo(const QString &path);
- explicit QStorageInfo(const QDir &dir);
- QStorageInfo(const QStorageInfo &other);
- ~QStorageInfo();
-
- QStorageInfo &operator=(const QStorageInfo &other);
-#ifdef Q_COMPILER_RVALUE_REFS
- inline QStorageInfo &operator=(QStorageInfo &&other)
- { qSwap(d, other.d); return *this; }
-#endif
-
- inline void swap(QStorageInfo &other)
- { qSwap(d, other.d); }
-
- void setPath(const QString &path);
-
- QString rootPath() const;
- QByteArray device() const;
- QByteArray fileSystemType() const;
- QString name() const;
- QString displayName() const;
-
- qint64 bytesTotal() const;
- qint64 bytesFree() const;
- qint64 bytesAvailable() const;
-
- inline bool isRoot() const;
- bool isReadOnly() const;
- bool isReady() const;
- bool isValid() const;
-
- void refresh();
-
- static QList<QStorageInfo> mountedVolumes();
- static QStorageInfo root();
-
-private:
- friend class QStorageInfoPrivate;
- friend bool operator==(const QStorageInfo &first, const QStorageInfo &second);
- QExplicitlySharedDataPointer<QStorageInfoPrivate> d;
-};
-
-inline bool operator==(const QStorageInfo &first, const QStorageInfo &second)
-{
- if (first.d == second.d)
- return true;
- return first.device() == second.device();
-}
-
-inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second)
-{
- return !(first == second);
-}
-
-inline bool QStorageInfo::isRoot() const
-{ return *this == QStorageInfo::root(); }
-
-Q_DECLARE_SHARED(QStorageInfo)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QStorageInfo)
-
-#endif // QSTORAGEINFO_H
=== removed file 'src/plugin/file-qml-plugin/qstorageinfo_p.h'
--- src/plugin/file-qml-plugin/qstorageinfo_p.h 2015-05-13 14:22:36 +0000
+++ src/plugin/file-qml-plugin/qstorageinfo_p.h 1970-01-01 00:00:00 +0000
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@xxxxxxxxx>
-** Contact: http://www.qt-project.org/legal
-**
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 3.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#ifndef QSTORAGEINFO_P_H
-#define QSTORAGEINFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qstorageinfo.h"
-
-QT_BEGIN_NAMESPACE
-
-class QStorageInfoPrivate : public QSharedData
-{
-public:
- inline QStorageInfoPrivate() : QSharedData(),
- bytesTotal(0), bytesFree(0), bytesAvailable(0),
- readOnly(false), ready(false), valid(false)
- {}
-
- void initRootPath();
- void doStat();
-
- static QList<QStorageInfo> mountedVolumes();
- static QStorageInfo root();
-
-protected:
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- void retreiveVolumeInfo();
- void retreiveDiskFreeSpace();
-#elif defined(Q_OS_MAC)
- void retrievePosixInfo();
- void retrieveUrlProperties(bool initRootPath = false);
- void retrieveLabel();
-#elif defined(Q_OS_UNIX)
- void retreiveVolumeInfo();
-#endif
-
-public:
- QString rootPath;
- QByteArray device;
- QByteArray fileSystemType;
- QString name;
-
- qint64 bytesTotal;
- qint64 bytesFree;
- qint64 bytesAvailable;
-
- bool readOnly;
- bool ready;
- bool valid;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSTORAGEINFO_P_H
=== removed file 'src/plugin/file-qml-plugin/qstorageinfo_unix.cpp'
--- src/plugin/file-qml-plugin/qstorageinfo_unix.cpp 2015-05-13 14:22:36 +0000
+++ src/plugin/file-qml-plugin/qstorageinfo_unix.cpp 1970-01-01 00:00:00 +0000
@@ -1,442 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@xxxxxxxxx>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; version 3.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see <http://www.gnu.org/licenses/>.
-**
-****************************************************************************/
-
-#include "qstorageinfo_p.h"
-
-#include <QtCore/qdiriterator.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qtextstream.h>
-
-// Copy this definition directly instead of importing the whole file which
-// would pull in more dependencies we don't need.
-//#include <QtCore/private/qcore_unix_p.h>
-#define EINTR_LOOP(var, cmd) \
- do { \
- var = cmd; \
- } while (var == -1 && errno == EINTR)
-
-#include <errno.h>
-#include <sys/stat.h>
-
-#if defined(Q_OS_BSD4)
-# include <sys/mount.h>
-# include <sys/statvfs.h>
-#elif defined(Q_OS_ANDROID)
-# include <sys/mount.h>
-# include <sys/vfs.h>
-# include <mntent.h>
-#elif defined(Q_OS_LINUX)
-# include <mntent.h>
-# include <sys/statvfs.h>
-#elif defined(Q_OS_SOLARIS)
-# include <sys/mnttab.h>
-#else
-# include <sys/statvfs.h>
-#endif
-
-#if defined(Q_OS_BSD4)
-# define QT_STATFSBUF struct statvfs
-# define QT_STATFS ::statvfs
-#elif defined(Q_OS_ANDROID)
-# define QT_STATFS ::statfs
-# define QT_STATFSBUF struct statfs
-# if !defined(ST_RDONLY)
-# define ST_RDONLY 1 // hack for missing define on Android
-# endif
-#else
-# if defined(QT_LARGEFILE_SUPPORT)
-# define QT_STATFSBUF struct statvfs64
-# define QT_STATFS ::statvfs64
-# else
-# define QT_STATFSBUF struct statvfs
-# define QT_STATFS ::statvfs
-# endif // QT_LARGEFILE_SUPPORT
-#endif // Q_OS_BSD4
-
-QT_BEGIN_NAMESPACE
-
-static bool isPseudoFs(const QString &mountDir, const QByteArray &type)
-{
- if (mountDir.startsWith(QLatin1String("/dev"))
- || mountDir.startsWith(QLatin1String("/proc"))
- || mountDir.startsWith(QLatin1String("/sys"))
- || mountDir.startsWith(QLatin1String("/var/run"))
- || mountDir.startsWith(QLatin1String("/var/lock"))) {
- return true;
- }
- if (type == "tmpfs")
- return true;
-#if defined(Q_OS_LINUX)
- if (type == "rootfs" || type == "rpc_pipefs")
- return true;
-#endif
-
- return false;
-}
-
-class QStorageIterator
-{
-public:
- QStorageIterator();
- ~QStorageIterator();
-
- inline bool isValid() const;
- inline bool next();
- inline QString rootPath() const;
- inline QByteArray fileSystemType() const;
- inline QByteArray device() const;
-private:
-#if defined(Q_OS_BSD4)
- struct statfs *stat_buf;
- int entryCount;
- int currentIndex;
-#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;
-#elif defined(Q_OS_LINUX)
- FILE *fp;
- mntent mnt;
- QByteArray buffer;
-#endif
-};
-
-#if defined(Q_OS_BSD4)
-
-inline QStorageIterator::QStorageIterator()
- : entryCount(::getmntinfo(&stat_buf, 0)),
- currentIndex(-1)
-{
-}
-
-inline QStorageIterator::~QStorageIterator()
-{
-}
-
-inline bool QStorageIterator::isValid() const
-{
- return entryCount != -1;
-}
-
-inline bool QStorageIterator::next()
-{
- return ++currentIndex < entryCount;
-}
-
-inline QString QStorageIterator::rootPath() const
-{
- return QFile::decodeName(stat_buf[currentIndex].f_mntonname);
-}
-
-inline QByteArray QStorageIterator::fileSystemType() const
-{
- return QByteArray(stat_buf[currentIndex].f_fstypename);
-}
-
-inline QByteArray QStorageIterator::device() const
-{
- return QByteArray(stat_buf[currentIndex].f_mntfromname);
-}
-
-#elif defined(Q_OS_SOLARIS)
-
-static const char pathMounted[] = "/etc/mnttab";
-
-inline QStorageIterator::QStorageIterator()
-{
- const int fd = qt_safe_open(pathMounted, O_RDONLY);
- fp = ::fdopen(fd, "r");
-}
-
-inline QStorageIterator::~QStorageIterator()
-{
- if (fp)
- ::fclose(fp);
-}
-
-inline bool QStorageIterator::isValid() const
-{
- return fp != Q_NULLPTR;
-}
-
-inline bool QStorageIterator::next()
-{
- return ::getmntent(fp, &mnt) == Q_NULLPTR;
-}
-
-inline QString QStorageIterator::rootPath() const
-{
- return QFile::decodeName(mnt->mnt_mountp);
-}
-
-inline QByteArray QStorageIterator::fileSystemType() const
-{
- return QByteArray(mnt->mnt_fstype);
-}
-
-inline QByteArray QStorageIterator::device() const
-{
- return QByteArray(mnt->mnt_mntopts);
-}
-
-#elif defined(Q_OS_ANDROID)
-
-static const char pathMounted[] = "/proc/mounts";
-
-inline QStorageIterator::QStorageIterator()
-{
- file.setFileName(pathMounted);
- file.open(QIODevice::ReadOnly | QIODevice::Text);
-}
-
-inline QStorageIterator::~QStorageIterator()
-{
-}
-
-inline bool QStorageIterator::isValid() const
-{
- return file.isOpen();
-}
-
-inline bool QStorageIterator::next()
-{
- QList<QByteArray> data;
- do {
- const QByteArray line = file.readLine();
- data = line.split(' ');
- } while (data.count() < 3 && !file.atEnd());
-
- if (file.atEnd())
- return false;
- m_device = data.at(0);
- m_rootPath = data.at(1);
- m_fileSystemType = data.at(2);
-
- 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;
-}
-
-#elif defined(Q_OS_LINUX)
-
-static const char pathMounted[] = "/etc/mtab";
-static const int bufferSize = 3*PATH_MAX; // 2 paths (mount point+device) and metainfo
-
-inline QStorageIterator::QStorageIterator() :
- buffer(QByteArray(bufferSize, 0))
-{
- fp = ::setmntent(pathMounted, "r");
-}
-
-inline QStorageIterator::~QStorageIterator()
-{
- if (fp)
- ::endmntent(fp);
-}
-
-inline bool QStorageIterator::isValid() const
-{
- return fp != Q_NULLPTR;
-}
-
-inline bool QStorageIterator::next()
-{
- return ::getmntent_r(fp, &mnt, buffer.data(), buffer.size()) != Q_NULLPTR;
-}
-
-inline QString QStorageIterator::rootPath() const
-{
- return QFile::decodeName(mnt.mnt_dir);
-}
-
-inline QByteArray QStorageIterator::fileSystemType() const
-{
- return QByteArray(mnt.mnt_type);
-}
-
-inline QByteArray QStorageIterator::device() const
-{
- return QByteArray(mnt.mnt_fsname);
-}
-
-#else
-
-inline QStorageIterator::QStorageIterator()
-{
-}
-
-inline QStorageIterator::~QStorageIterator()
-{
-}
-
-inline bool QStorageIterator::isValid() const
-{
- return false;
-}
-
-inline bool QStorageIterator::next()
-{
- return false;
-}
-
-inline QString QStorageIterator::rootPath() const
-{
- return QString();
-}
-
-inline QByteArray QStorageIterator::fileSystemType() const
-{
- return QByteArray();
-}
-
-inline QByteArray QStorageIterator::device() const
-{
- return QByteArray();
-}
-
-#endif
-
-void QStorageInfoPrivate::initRootPath()
-{
- rootPath = QFileInfo(rootPath).canonicalFilePath();
-
- if (rootPath.isEmpty())
- return;
-
- QStorageIterator it;
- if (!it.isValid()) {
- rootPath = QStringLiteral("/");
- return;
- }
-
- int maxLength = 0;
- const QString oldRootPath = rootPath;
- rootPath.clear();
-
- while (it.next()) {
- const QString mountDir = it.rootPath();
- const QByteArray fsName = it.fileSystemType();
- if (isPseudoFs(mountDir, fsName))
- continue;
- // we try to find most suitable entry
- if (oldRootPath.startsWith(mountDir) && maxLength < mountDir.length()) {
- maxLength = mountDir.length();
- rootPath = mountDir;
- device = it.device();
- fileSystemType = fsName;
- }
- }
-}
-
-static inline QString retrieveLabel(const QByteArray &device)
-{
-#ifdef Q_OS_LINUX
- static const char pathDiskByLabel[] = "/dev/disk/by-label";
-
- QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot);
- while (it.hasNext()) {
- it.next();
- QFileInfo fileInfo(it.fileInfo());
- if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device)
- return fileInfo.fileName();
- }
-#else
- Q_UNUSED(device);
-#endif
-
- return QString();
-}
-
-void QStorageInfoPrivate::doStat()
-{
- initRootPath();
- if (rootPath.isEmpty())
- return;
-
- retreiveVolumeInfo();
- name = retrieveLabel(device);
-}
-
-void QStorageInfoPrivate::retreiveVolumeInfo()
-{
- QT_STATFSBUF statfs_buf;
- int result;
- EINTR_LOOP(result, QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf));
- if (result == 0) {
- valid = true;
- ready = true;
-
- bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
- bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
- bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
-#if defined(Q_OS_ANDROID)
-#if defined(_STATFS_F_FLAGS)
- readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
-#endif
-#else
- readOnly = (statfs_buf.f_flag & ST_RDONLY) != 0;
-#endif
- }
-}
-
-QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
-{
- QStorageIterator it;
- if (!it.isValid())
- return QList<QStorageInfo>() << root();
-
- QList<QStorageInfo> volumes;
-
- while (it.next()) {
- const QString mountDir = it.rootPath();
- const QByteArray fsName = it.fileSystemType();
- if (isPseudoFs(mountDir, fsName))
- continue;
-
- volumes.append(QStorageInfo(mountDir));
- }
-
- return volumes;
-}
-
-QStorageInfo QStorageInfoPrivate::root()
-{
- return QStorageInfo(QStringLiteral("/"));
-}
-
-QT_END_NAMESPACE
Follow ups