21 list << QString::number(
m_local);
22 list << QString::number(
m_fsid);
23 list << QString::number(
m_grpid);
25 list << QString::number(
m_total);
26 list << QString::number(
m_used);
40 QStringList::const_iterator it = slist.cbegin();
55 const QStringList::const_iterator& listend)
57 if (std::distance(it, listend) <
kLines)
59 LOG(VB_GENERAL, LOG_ALERT, QStringLiteral(
"FileSystemInfo::FromStringList, not enough items in list."));
67 m_local = (*it).toLongLong(); it++;
68 m_fsid = (*it).toLongLong(); it++;
69 m_grpid = (*it).toLongLong(); it++;
71 m_total = (*it).toLongLong(); it++;
72 m_used = (*it).toLongLong(); it++;
83 if (
info.isValid() &&
info.isReady())
94 QByteArray device =
info.device();
95 m_local = (device.startsWith(R
"(\\?\)") && !device.startsWith(R"(\\?\UNC\)")) ||
96 (device.startsWith(R"(\\.\)") && !device.startsWith(R"(\\.\UNC\)"));
109 QStringList strlist(QStringLiteral(
"QUERY_FREE_SPACE_LIST"));
111 if ((sock !=
nullptr)
124 bool merge, int64_t fuzz,
125 const QString& total_name)
128 int64_t total_total = 0;
129 int64_t total_used = 0;
132#
if QT_VERSION < QT_VERSION_CHECK(6,0,0)
133 auto* it1 = disks.begin();
135 auto it1 = disks.begin();
137 it1 != disks.end(); ++it1)
139 if (it1->getFSysID() == -1)
141 it1->setFSysID(newid++);
142 total_total += it1->getTotalSpace();
143 total_used += it1->getUsedSpace();
145 it1->setPath(it1->getHostname().section(
".", 0, 0)
146 +
":" + it1->getPath());
150#
if QT_VERSION < QT_VERSION_CHECK(6,0,0)
155 it2 != disks.end(); ++it2)
157 if (it2->getFSysID() != -1)
161 int bSize = std::max( {32 << 10, it1->getBlockSize(), it2->getBlockSize()} );
163 int64_t diffSize = std::abs(it1->getTotalSpace() - it2->getTotalSpace());
164 int64_t diffUsed = std::abs(it1->getUsedSpace() - it2->getUsedSpace());
166 if ((diffSize <= bSize) && (diffUsed <= fuzz))
168 it2->setFSysID(it1->getFSysID());
172 if (!it1->getHostname().contains(it2->getHostname()))
173 it1->setHostname(it1->getHostname()
174 +
"," + it2->getHostname());
175 it1->setPath(it1->getPath() +
","
176 + it2->getHostname().section(
".", 0, 0) +
":"
184 if (!total_name.isEmpty())
186 disks.append(
FileSystemInfo(total_name,
"TotalDiskSpace",
false, -2, -2,
187 0, total_total, total_used));
196 QStringList::const_iterator it = list.cbegin();
197 while (it < list.cend())
208 for (
const auto & fsInfo : fsInfos)
210 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={})