summaryrefslogtreecommitdiffstats
path: root/api/logic/modplatform/ftb/FtbPrivatePackManager.cpp
blob: 15449592f76d7c0bdc8a35059248aeef856e59db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "FtbPrivatePackManager.h"

#include <QDebug>

#include "FileSystem.h"

void FtbPrivatePackManager::load()
{
    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;
    }
}

void FtbPrivatePackManager::save() const
{
    if(!dirty)
    {
        return;
    }
    try
    {
        FS::write(m_filename, currentPacks.toList().join('\n').toUtf8());
        dirty = false;
    }
    catch(...)
    {
        qWarning() << "Failed to write third party FTB pack codes to" << m_filename;
    }
}