8#include <QtCore/qdiriterator.h>
9#include <QtCore/qfileinfo.h>
10#include <QtCore/qtextstream.h>
12#include <QtCore/private/qcore_unix_p.h>
13#include <QtCore/private/qlocale_tools_p.h>
19# include <sys/mount.h>
20# include <sys/statvfs.h>
21#elif defined(Q_OS_HURD)
23# include <sys/statvfs.h>
24# include <sys/sysmacros.h>
25#elif defined(Q_OS_SOLARIS)
26# include <sys/mnttab.h>
27# include <sys/statvfs.h>
28#elif defined(Q_OS_HAIKU)
29# include <Directory.h>
32# include <VolumeRoster.h>
34# include <sys/statvfs.h>
36# include <sys/statvfs.h>
40# if defined(Q_OS_NETBSD)
41# define QT_STATFSBUF struct statvfs
42# define QT_STATFS ::statvfs
44# define QT_STATFSBUF struct statfs
45# define QT_STATFS ::statfs
48# if !defined(ST_RDONLY)
49# define ST_RDONLY MNT_RDONLY
51# if !defined(_STATFS_F_FLAGS) && !defined(Q_OS_NETBSD)
52# define _STATFS_F_FLAGS 1
54#elif defined(Q_OS_HAIKU)
55# define QT_STATFSBUF struct statvfs
56# define QT_STATFS ::statvfs
58# if defined(QT_LARGEFILE_SUPPORT)
59# define QT_STATFSBUF struct statvfs64
60# define QT_STATFS ::statvfs64
62# define QT_STATFSBUF struct statvfs
63# define QT_STATFS ::statvfs
67#if __has_include(<paths.h>)
71# define _PATH_MOUNTED "/etc/mnttab"
96#elif defined(Q_OS_SOLARIS)
99#elif defined(Q_OS_HURD)
103#elif defined(Q_OS_HAIKU)
104 BVolumeRoster m_volumeRoster;
112#if defined(Q_OS_BSD4)
119 : entryCount(::getmntinfo(&stat_buf, MNT_NOWAIT)),
130 return entryCount != -1;
135 return ++currentIndex < entryCount;
145 return QByteArray(stat_buf[currentIndex].f_fstypename);
150 return QByteArray(stat_buf[currentIndex].f_mntfromname);
162#elif defined(Q_OS_SOLARIS)
167 fp = ::fdopen(
fd,
"r");
178 return fp !=
nullptr;
183 return ::getmntent(
fp, &mnt) == 0;
206#elif defined(Q_OS_HURD)
208static const int bufferSize = 1024;
225 return fp !=
nullptr;
230 return ::getmntent_r(
fp, &mnt,
buffer.data(),
buffer.size()) !=
nullptr;
257#elif defined(Q_OS_HAIKU)
275 if (m_volumeRoster.GetNextVolume(&volume) != B_OK)
279 if (volume.GetRootDirectory(&
directory) != B_OK)
285 memset(&fsInfo, 0,
sizeof(fsInfo));
287 if (fs_stat_dev(volume.Device(), &fsInfo) != 0)
290 m_rootPath =
path.Path();
291 m_fileSystemType =
QByteArray(fsInfo.fsh_name);
306 return m_fileSystemType;
372#if defined Q_OS_HAIKU
374 memset(&fsInfo, 0,
sizeof(fsInfo));
378 while ((dev = next_dev(&
pos)) >= 0) {
379 if (fs_stat_dev(dev, &fsInfo) != 0)
392void QStorageInfoPrivate::doStat()
395 if (rootPath.isEmpty())
398 retrieveVolumeInfo();
402void QStorageInfoPrivate::retrieveVolumeInfo()
411#if defined(Q_OS_INTEGRITY) || (defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)) || defined(Q_OS_RTEMS)
412 bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
413 bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
414 bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
416 bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
417 bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
418 bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
421#if defined(Q_OS_ANDROID) || defined(Q_OS_BSD4) || defined(Q_OS_INTEGRITY) || defined(Q_OS_RTEMS)
422#if defined(_STATFS_F_FLAGS)
423 readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
426 readOnly = (statfs_buf.f_flag & ST_RDONLY) != 0;
431void QStorageInfoPrivate::initRootPath()
435 if (rootPath.isEmpty())
445 const QString oldRootPath = rootPath;
456 fileSystemType = fsName;
457 subvolume =
it.subvolume();
476 info.d->device =
it.device();
477 info.d->fileSystemType =
it.fileSystemType();
478 info.d->subvolume =
it.subvolume();
479 if (
info.bytesTotal() == 0 &&
info != root())
IOBluetoothDevice * device
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
\inmodule QtCore \reentrant
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
void append(parameter_type t)
QByteArray device() const
QByteArray subvolume() const
QByteArray options() const
QByteArray fileSystemType() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
#define EINTR_LOOP(var, cmd)
GLsizei const GLchar *const * path
static bool shouldIncludeFs(const QString &mountDir, const QByteArray &fsType)
QT_BEGIN_NAMESPACE static Q_LOGGING_CATEGORY(lcStorageInfo, "qt.core.qstorageinfo", QtWarningMsg) class QStorageInfoPrivate bool isParentOf(const String &parent, const QString &dirName)
static QString retrieveLabel(const QByteArray &device)
#define QStringLiteral(str)
QFileInfo info(fileName)
[8]