2019-08-04 06:57:53 +05:30
|
|
|
#include "ModFolderLoadTask.h"
|
|
|
|
#include <QDebug>
|
|
|
|
|
2022-04-15 08:54:57 +05:30
|
|
|
#include "modplatform/packwiz/Packwiz.h"
|
|
|
|
|
2022-04-16 06:37:35 +05:30
|
|
|
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
|
|
|
|
: m_mods_dir(mods_dir), m_index_dir(index_dir), m_result(new Result())
|
|
|
|
{}
|
2019-08-04 06:57:53 +05:30
|
|
|
|
|
|
|
void ModFolderLoadTask::run()
|
|
|
|
{
|
2022-04-15 08:54:57 +05:30
|
|
|
// Read metadata first
|
|
|
|
m_index_dir.refresh();
|
2022-04-16 06:37:35 +05:30
|
|
|
for (auto entry : m_index_dir.entryList()) {
|
2022-04-15 08:54:57 +05:30
|
|
|
// QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
|
2022-04-16 06:37:35 +05:30
|
|
|
if (entry == "." || entry == "..")
|
2022-04-15 08:54:57 +05:30
|
|
|
continue;
|
|
|
|
|
2022-04-16 06:37:35 +05:30
|
|
|
entry.chop(5); // Remove .toml at the end
|
2022-04-15 08:54:57 +05:30
|
|
|
Mod mod(m_mods_dir, Packwiz::getIndexForMod(m_index_dir, entry));
|
2022-04-16 06:37:35 +05:30
|
|
|
m_result->mods[mod.internal_id()] = mod;
|
2022-04-15 08:54:57 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
// Read JAR files that don't have metadata
|
|
|
|
m_mods_dir.refresh();
|
2022-04-16 06:37:35 +05:30
|
|
|
for (auto entry : m_mods_dir.entryInfoList()) {
|
2022-04-15 08:54:57 +05:30
|
|
|
Mod mod(entry);
|
2022-04-16 06:37:35 +05:30
|
|
|
if (!m_result->mods.contains(mod.internal_id()))
|
|
|
|
m_result->mods[mod.internal_id()] = mod;
|
2019-08-04 06:57:53 +05:30
|
|
|
}
|
2022-04-15 08:54:57 +05:30
|
|
|
|
2019-08-04 06:57:53 +05:30
|
|
|
emit succeeded();
|
|
|
|
}
|