8#include <QtCore/qfileinfo.h>
9#include <QtCore/qtextstream.h>
11#include <QtCore/private/qcore_unix_p.h>
12#include <QtCore/private/qlocale_tools_p.h>
18# include <sys/mount.h>
19# include <sys/statvfs.h>
20#elif defined(Q_OS_HURD)
22# include <sys/statvfs.h>
23# include <sys/sysmacros.h>
24#elif defined(Q_OS_SOLARIS)
25# include <sys/mnttab.h>
26# include <sys/statvfs.h>
27#elif defined(Q_OS_HAIKU)
28# include <Directory.h>
31# include <VolumeRoster.h>
33# include <sys/statvfs.h>
35# include <sys/statvfs.h>
39# if defined(Q_OS_NETBSD)
40# define QT_STATFSBUF struct statvfs
41# define QT_STATFS ::statvfs
43# define QT_STATFSBUF struct statfs
44# define QT_STATFS ::statfs
47# if !defined(ST_RDONLY)
48# define ST_RDONLY MNT_RDONLY
50# if !defined(_STATFS_F_FLAGS) && !defined(Q_OS_NETBSD)
51# define _STATFS_F_FLAGS 1
53#elif defined(Q_OS_HAIKU)
54# define QT_STATFSBUF struct statvfs
55# define QT_STATFS ::statvfs
57# if defined(QT_LARGEFILE_SUPPORT)
58# define QT_STATFSBUF struct statvfs64
59# define QT_STATFS ::statvfs64
61# define QT_STATFSBUF struct statvfs
62# define QT_STATFS ::statvfs
66#if __has_include(<paths.h>)
70# define _PATH_MOUNTED "/etc/mnttab"
95#elif defined(Q_OS_SOLARIS)
98#elif defined(Q_OS_HURD)
102#elif defined(Q_OS_HAIKU)
103 BVolumeRoster m_volumeRoster;
111#if defined(Q_OS_BSD4)
118 : entryCount(::getmntinfo(&stat_buf, MNT_NOWAIT)),
129 return entryCount != -1;
134 return ++currentIndex < entryCount;
144 return QByteArray(stat_buf[currentIndex].f_fstypename);
149 return QByteArray(stat_buf[currentIndex].f_mntfromname);
161#elif defined(Q_OS_SOLARIS)
166 fp = ::fdopen(
fd,
"r");
177 return fp !=
nullptr;
182 return ::getmntent(
fp, &mnt) == 0;
205#elif defined(Q_OS_HURD)
207static const int bufferSize = 1024;
224 return fp !=
nullptr;
229 return ::getmntent_r(
fp, &mnt,
buffer.data(),
buffer.size()) !=
nullptr;
256#elif defined(Q_OS_HAIKU)
274 if (m_volumeRoster.GetNextVolume(&volume) != B_OK)
278 if (volume.GetRootDirectory(&
directory) != B_OK)
284 memset(&fsInfo, 0,
sizeof(fsInfo));
286 if (fs_stat_dev(volume.Device(), &fsInfo) != 0)
289 m_rootPath =
path.Path();
290 m_fileSystemType =
QByteArray(fsInfo.fsh_name);
305 return m_fileSystemType;
371#if defined Q_OS_HAIKU
373 memset(&fsInfo, 0,
sizeof(fsInfo));
377 while ((dev = next_dev(&
pos)) >= 0) {
378 if (fs_stat_dev(dev, &fsInfo) != 0)
391void QStorageInfoPrivate::doStat()
394 if (rootPath.isEmpty())
397 retrieveVolumeInfo();
401void QStorageInfoPrivate::retrieveVolumeInfo()
410#if defined(Q_OS_INTEGRITY) || (defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)) || defined(Q_OS_RTEMS)
411 bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
412 bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
413 bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
415 bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
416 bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
417 bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
420#if defined(Q_OS_ANDROID) || defined(Q_OS_BSD4) || defined(Q_OS_INTEGRITY) || defined(Q_OS_RTEMS)
421#if defined(_STATFS_F_FLAGS)
422 readOnly = (statfs_buf.f_flags &
ST_RDONLY) != 0;
425 readOnly = (statfs_buf.f_flag &
ST_RDONLY) != 0;
430void QStorageInfoPrivate::initRootPath()
434 if (rootPath.isEmpty())
444 const QString oldRootPath = rootPath;
455 fileSystemType = fsName;
456 subvolume =
it.subvolume();
461QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
465 return QList<QStorageInfo>() << root();
467 QList<QStorageInfo> volumes;
475 info.d->device =
it.device();
476 info.d->fileSystemType =
it.fileSystemType();
477 info.d->subvolume =
it.subvolume();
478 if (
info.bytesTotal() <= 0 &&
info != root())
480 volumes.append(
info);
IOBluetoothDevice * device
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
QString canonicalFilePath() const
Returns the file system entry's canonical path, including the entry's name, that is,...
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.
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...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
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 QT_EINTR_LOOP(var, cmd)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
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)