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"
|
|
|
|
|
|
|
|
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();
|
|
|
|
for(auto entry : m_index_dir.entryList()){
|
|
|
|
// QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
|
|
|
|
if(entry == "." || entry == "..")
|
|
|
|
continue;
|
|
|
|
|
|
|
|
entry.chop(5); // Remove .toml at the end
|
|
|
|
Mod mod(m_mods_dir, Packwiz::getIndexForMod(m_index_dir, entry));
|
|
|
|
m_result->mods[mod.mmc_id()] = mod;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read JAR files that don't have metadata
|
|
|
|
m_mods_dir.refresh();
|
|
|
|
for (auto entry : m_mods_dir.entryInfoList())
|
2019-08-04 06:57:53 +05:30
|
|
|
{
|
2022-04-15 08:54:57 +05:30
|
|
|
Mod mod(entry);
|
|
|
|
if(!m_result->mods.contains(mod.mmc_id()))
|
|
|
|
m_result->mods[mod.mmc_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();
|
|
|
|
}
|