2019-11-03 22:48:12 +00:00
|
|
|
#include "PrivatePackManager.h"
|
2018-08-01 22:52:31 +00:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "FileSystem.h"
|
|
|
|
|
2019-11-03 22:48:12 +00:00
|
|
|
namespace LegacyFTB {
|
|
|
|
|
|
|
|
void PrivatePackManager::load()
|
2018-08-01 22:52:31 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
currentPacks = QString::fromUtf8(FS::read(m_filename)).split('\n', QString::SkipEmptyParts).toSet();
|
|
|
|
dirty = false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
currentPacks = {};
|
|
|
|
qWarning() << "Failed to read third party FTB pack codes from" << m_filename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-03 22:48:12 +00:00
|
|
|
void PrivatePackManager::save() const
|
2018-08-01 22:52:31 +00:00
|
|
|
{
|
|
|
|
if(!dirty)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
2018-08-01 23:12:41 +00:00
|
|
|
QStringList list = currentPacks.toList();
|
|
|
|
FS::write(m_filename, list.join('\n').toUtf8());
|
2018-08-01 22:52:31 +00:00
|
|
|
dirty = false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
qWarning() << "Failed to write third party FTB pack codes to" << m_filename;
|
|
|
|
}
|
|
|
|
}
|
2019-11-03 22:48:12 +00:00
|
|
|
|
|
|
|
}
|