4#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
5#include <QtSystemDetection>
11#include <QStorageInfo>
24 list << QString::number(
m_local);
25 list << QString::number(
m_fsid);
26 list << QString::number(
m_grpid);
28 list << QString::number(
m_total);
29 list << QString::number(
m_used);
43 QStringList::const_iterator it = slist.cbegin();
58 const QStringList::const_iterator& listend)
60 if (std::distance(it, listend) <
kLines)
62 LOG(VB_GENERAL, LOG_ALERT, QStringLiteral(
"FileSystemInfo::FromStringList, not enough items in list."));
70 m_local = (*it).toLongLong(); it++;
71 m_fsid = (*it).toLongLong(); it++;
72 m_grpid = (*it).toLongLong(); it++;
74 m_total = (*it).toLongLong(); it++;
75 m_used = (*it).toLongLong(); it++;
86 if (
info.isValid() &&
info.isReady())
97 QByteArray device =
info.device();
98 m_local = (device.startsWith(R
"(\\?\)") && !device.startsWith(R"(\\?\UNC\)")) ||
99 (device.startsWith(R"(\\.\)") && !device.startsWith(R"(\\.\UNC\)"));
112 QStringList strlist(QStringLiteral(
"QUERY_FREE_SPACE_LIST"));
114 if ((sock !=
nullptr)
127 bool merge, int64_t fuzz,
128 const QString& total_name)
131 int64_t total_total = 0;
132 int64_t total_used = 0;
135#
if QT_VERSION < QT_VERSION_CHECK(6,0,0)
136 auto* it1 = disks.begin();
138 auto it1 = disks.begin();
140 it1 != disks.end(); ++it1)
142 if (it1->getFSysID() == -1)
144 it1->setFSysID(newid++);
145 total_total += it1->getTotalSpace();
146 total_used += it1->getUsedSpace();
148 it1->setPath(it1->getHostname().section(
".", 0, 0)
149 +
":" + it1->getPath());
153#
if QT_VERSION < QT_VERSION_CHECK(6,0,0)
158 it2 != disks.end(); ++it2)
160 if (it2->getFSysID() != -1)
164 int bSize = std::max( {32 << 10, it1->getBlockSize(), it2->getBlockSize()} );
166 int64_t diffSize = std::abs(it1->getTotalSpace() - it2->getTotalSpace());
167 int64_t diffUsed = std::abs(it1->getUsedSpace() - it2->getUsedSpace());
169 if ((diffSize <= bSize) && (diffUsed <= fuzz))
171 it2->setFSysID(it1->getFSysID());
175 if (!it1->getHostname().contains(it2->getHostname()))
176 it1->setHostname(it1->getHostname()
177 +
"," + it2->getHostname());
178 it1->setPath(it1->getPath() +
","
179 + it2->getHostname().section(
".", 0, 0) +
":"
187 if (!total_name.isEmpty())
189 disks.append(
FileSystemInfo(total_name,
"TotalDiskSpace",
false, -2, -2,
190 0, total_total, total_used));
199 QStringList::const_iterator it = list.cbegin();
200 while (it < list.cend())
211 for (
const auto & fsInfo : fsInfos)
213 strlist << fsInfo.ToStringList();
int m_fsid
set by Consolidate
int m_grpid
set by setGroupID
static constexpr int kLines
number of strings in the serialized stringlist
bool m_local
set based on QStorageInfo::device()
int m_weight
set by setWeight
QStringList ToStringList() const
bool FromStringList(const QStringList &slist)
bool refresh()
update filesystem statistics by reading from the storage device
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
Class for communcating between myth backends and frontends.
bool SendReceiveStringList(QStringList &list, uint min_reply_length=0, std::chrono::milliseconds timeoutMS=kLongTimeout)
QVector< FileSystemInfo > FileSystemInfoList
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MBASE_PUBLIC FileSystemInfoList GetInfoList(MythSocket *sock=nullptr)
MBASE_PUBLIC QStringList ToStringList(const FileSystemInfoList &fsInfos)
MBASE_PUBLIC FileSystemInfoList FromStringList(const QStringList &list)
MBASE_PUBLIC void Consolidate(FileSystemInfoList &disks, bool merge, int64_t fuzz, const QString &total_name={})