2019-11-04 04:18:12 +05:30
|
|
|
#include "PrivatePackManager.h"
|
2018-08-02 04:22:31 +05:30
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "FileSystem.h"
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
namespace LegacyFTB {
|
|
|
|
|
|
|
|
void PrivatePackManager::load()
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2022-05-02 22:40:45 +05:30
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
|
|
auto foo = QString::fromUtf8(FS::read(m_filename)).split('\n', Qt::SkipEmptyParts);
|
|
|
|
currentPacks = QSet<QString>(foo.begin(), foo.end());
|
|
|
|
#else
|
2018-08-02 04:22:31 +05:30
|
|
|
currentPacks = QString::fromUtf8(FS::read(m_filename)).split('\n', QString::SkipEmptyParts).toSet();
|
2022-05-02 22:40:45 +05:30
|
|
|
#endif
|
|
|
|
|
2018-08-02 04:22:31 +05:30
|
|
|
dirty = false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
currentPacks = {};
|
|
|
|
qWarning() << "Failed to read third party FTB pack codes from" << m_filename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void PrivatePackManager::save() const
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
if(!dirty)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
2022-05-02 22:40:45 +05:30
|
|
|
QStringList list = currentPacks.values();
|
2018-08-02 04:42:41 +05:30
|
|
|
FS::write(m_filename, list.join('\n').toUtf8());
|
2018-08-02 04:22:31 +05:30
|
|
|
dirty = false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
qWarning() << "Failed to write third party FTB pack codes to" << m_filename;
|
|
|
|
}
|
|
|
|
}
|
2019-11-04 04:18:12 +05:30
|
|
|
|
|
|
|
}
|