diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-04-02 00:59:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-02 00:59:15 +0200 |
commit | 333f7cc32030c9ae020a955501f6929e6927f1e4 (patch) | |
tree | 8d553305dcc0c51bc06e2678d82f04498db958e0 /launcher/minecraft/World.cpp | |
parent | 269c1bbf5892180f6008cc592126bc6400b5e4f5 (diff) | |
parent | e8697068fb5baa454ad97ae272726f98d2108f94 (diff) | |
download | PrismLauncher-333f7cc32030c9ae020a955501f6929e6927f1e4.tar.gz PrismLauncher-333f7cc32030c9ae020a955501f6929e6927f1e4.tar.bz2 PrismLauncher-333f7cc32030c9ae020a955501f6929e6927f1e4.zip |
Merge pull request #373 from Scrumplex/feat-world-size
Diffstat (limited to 'launcher/minecraft/World.cpp')
-rw-r--r-- | launcher/minecraft/World.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp index 2937c116..9cf67ed9 100644 --- a/launcher/minecraft/World.cpp +++ b/launcher/minecraft/World.cpp @@ -17,6 +17,7 @@ #include <QString> #include <QDebug> #include <QSaveFile> +#include <QDirIterator> #include "World.h" #include "GZip.h" @@ -187,6 +188,26 @@ bool putLevelDatDataToFS(const QFileInfo &file, QByteArray & data) return f.commit(); } +int64_t calculateWorldSize(const QFileInfo &file) +{ + if (file.isFile() && file.suffix() == "zip") + { + return file.size(); + } + else if(file.isDir()) + { + QDirIterator it(file.absolutePath(), QDirIterator::Subdirectories); + int64_t total = 0; + while (it.hasNext()) + { + total += it.fileInfo().size(); + it.next(); + } + return total; + } + return -1; +} + World::World(const QFileInfo &file) { repath(file); @@ -196,6 +217,7 @@ void World::repath(const QFileInfo &file) { m_containerFile = file; m_folderName = file.fileName(); + m_size = calculateWorldSize(file); if(file.isFile() && file.suffix() == "zip") { m_iconFile = QString(); @@ -482,6 +504,7 @@ void World::loadFromLevelDat(QByteArray data) if(randomSeed) { qDebug() << "Seed:" << *randomSeed; } + qDebug() << "Size:" << m_size; qDebug() << "GameType:" << m_gameType.toLogString(); } |