diff options
Diffstat (limited to 'api/logic/modplatform/ftb/FtbPrivatePackManager.cpp')
-rw-r--r-- | api/logic/modplatform/ftb/FtbPrivatePackManager.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/api/logic/modplatform/ftb/FtbPrivatePackManager.cpp b/api/logic/modplatform/ftb/FtbPrivatePackManager.cpp new file mode 100644 index 00000000..15449592 --- /dev/null +++ b/api/logic/modplatform/ftb/FtbPrivatePackManager.cpp @@ -0,0 +1,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; + } +} |