mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 15:46:18 +00:00
Changed: Added getDirectorySize() function
This commit is contained in:
parent
482865ca74
commit
f96d20dedb
2 changed files with 29 additions and 0 deletions
|
@ -34,6 +34,33 @@ QString qBytesToHumanReadable(qint64 bytes)
|
||||||
return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str());
|
return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 getDirectorySize(const QString &directory)
|
||||||
|
{
|
||||||
|
qint64 size = 0;
|
||||||
|
QDir dir(directory);
|
||||||
|
|
||||||
|
if (dir.exists())
|
||||||
|
{
|
||||||
|
QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo = list.at(i);
|
||||||
|
|
||||||
|
if (fileInfo.isDir())
|
||||||
|
{
|
||||||
|
size += getDirectorySize(fileInfo.absoluteFilePath());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size += fileInfo.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
QString qFromUtf8(const std::string &str)
|
QString qFromUtf8(const std::string &str)
|
||||||
{
|
{
|
||||||
return QString::fromUtf8(str.c_str());
|
return QString::fromUtf8(str.c_str());
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
QString qBytesToHumanReadable(qint64 bytes);
|
QString qBytesToHumanReadable(qint64 bytes);
|
||||||
|
|
||||||
|
qint64 getDirectorySize(const QString &directory);
|
||||||
|
|
||||||
// Convert a UTF-8 string to QString
|
// Convert a UTF-8 string to QString
|
||||||
QString qFromUtf8(const std::string &str);
|
QString qFromUtf8(const std::string &str);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue