summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/pluginlist.cpp285
-rw-r--r--src/pluginlist.h34
-rw-r--r--src/profile.cpp2
-rw-r--r--src/safewritefile.cpp71
-rw-r--r--src/safewritefile.h57
7 files changed, 90 insertions, 363 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6eec86a9..1bd16ed3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -76,7 +76,6 @@ SET(organizer_SRCS
previewdialog.cpp
aboutdialog.cpp
json.cpp
- safewritefile.cpp
modflagicondelegate.cpp
genericicondelegate.cpp
organizerproxy.cpp
@@ -162,7 +161,6 @@ SET(organizer_HDRS
previewdialog.h
aboutdialog.h
json.h
- safewritefile.h
modflagicondelegate.h
genericicondelegate.h
organizerproxy.h
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 05000761..24391999 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -71,7 +71,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "previewdialog.h"
#include "browserdialog.h"
#include "aboutdialog.h"
-#include "safewritefile.h"
+#include <safewritefile.h>
#include "nxmaccessmanager.h"
#include "appconfig.h"
#include "eventfilter.h"
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index bf5a09dc..8110cdf2 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -20,7 +20,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "pluginlist.h"
#include "inject.h"
#include "settings.h"
-#include "safewritefile.h"
#include "scopeguard.h"
#include "modinfo.h"
#include <utility.h>
@@ -28,6 +27,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <espfile.h>
#include <report.h>
#include <windows_error.h>
+#include <safewritefile.h>
+#include <gameplugins.h>
#include <QtDebug>
#include <QMessageBox>
@@ -74,14 +75,6 @@ PluginList::PluginList(QObject *parent)
: QAbstractItemModel(parent)
, m_FontMetrics(QFont())
{
- m_Utf8Codec = QTextCodec::codecForName("utf-8");
- m_LocalCodec = QTextCodec::codecForName("Windows-1252");
-
- if (m_LocalCodec == nullptr) {
- qCritical("required 8-bit string-encoding not supported.");
- m_LocalCodec = m_Utf8Codec;
- }
-
}
PluginList::~PluginList()
@@ -117,27 +110,25 @@ QString PluginList::getColumnToolTip(int column)
void PluginList::refresh(const QString &profileName
, const DirectoryEntry &baseDirectory
- , const QString &pluginsFile
- , const QString &loadOrderFile
, const QString &lockedOrderFile)
{
ChangeBracket<PluginList> layoutChange(this);
- m_ESPsByName.clear();
- m_ESPsByPriority.clear();
- m_ESPs.clear();
-
QStringList primaryPlugins = m_GamePlugin->primaryPlugins();
m_CurrentProfile = profileName;
std::vector<FileEntry::Ptr> files = baseDirectory.getFiles();
- for (auto iter = files.begin(); iter != files.end(); ++iter) {
- FileEntry::Ptr current = *iter;
+ for (FileEntry::Ptr current : files) {
if (current.get() == nullptr) {
continue;
}
QString filename = ToQString(current->getName());
+
+ if (m_ESPsByName.find(filename.toLower()) != m_ESPsByName.end()) {
+ continue;
+ }
+
QString extension = filename.right(3).toLower();
if ((extension == "esp") || (extension == "esm")) {
@@ -165,56 +156,24 @@ void PluginList::refresh(const QString &profileName
}
}
- if (readLoadOrder(loadOrderFile)) {
- int maxPriority = 0;
- // assign known load orders
- for (std::vector<ESPInfo>::iterator espIter = m_ESPs.begin(); espIter != m_ESPs.end(); ++espIter) {
- std::map<QString, int>::const_iterator priorityIter = m_ESPLoadOrder.find(espIter->m_Name.toLower());
- if (priorityIter != m_ESPLoadOrder.end()) {
- if (priorityIter->second > maxPriority) {
- maxPriority = priorityIter->second;
- }
- espIter->m_Priority = priorityIter->second;
- } else {
- espIter->m_Priority = -1;
- }
- }
-
- ++maxPriority;
-
- // assign maximum priorities for plugins with unknown priority
- for (std::vector<ESPInfo>::iterator espIter = m_ESPs.begin(); espIter != m_ESPs.end(); ++espIter) {
- if (espIter->m_Priority == -1) {
- espIter->m_Priority = maxPriority++;
- }
- }
- } else {
- // no load order stored, determine by date
- std::sort(m_ESPs.begin(), m_ESPs.end(), ByDate);
-
- for (size_t i = 0; i < m_ESPs.size(); ++i) {
- m_ESPs[i].m_Priority = i;
- }
- }
+ // functions in GamePlugins will use the IPluginList interface of this, so
+ // indices need to work. priority will be off however
+ updateIndices();
- std::sort(m_ESPs.begin(), m_ESPs.end(), ByPriority); // first, sort by priority
- // remove gaps from the priorities so we can use them as array indices without overflow
- for (int i = 0; i < static_cast<int>(m_ESPs.size()); ++i) {
- m_ESPs[i].m_Priority = i;
- }
+ GamePlugins *gamePlugins = m_GamePlugin->feature<GamePlugins>();
+ gamePlugins->readPluginLists(this);
- std::sort(m_ESPs.begin(), m_ESPs.end(), ByName); // sort by name so alphabetical sorting works
+ testMasters();
updateIndices();
- readEnabledFrom(pluginsFile);
-
readLockedOrderFrom(lockedOrderFile);
layoutChange.finish();
refreshLoadOrder();
- emit dataChanged(this->index(0, 0), this->index(m_ESPs.size(), columnCount()));
+ emit dataChanged(this->index(0, 0),
+ this->index(static_cast<int>(m_ESPs.size()), columnCount()));
m_Refreshed();
}
@@ -301,89 +260,6 @@ bool PluginList::isEnabled(int index)
return m_ESPs.at(index).m_Enabled;
}
-bool PluginList::readLoadOrder(const QString &fileName)
-{
- std::set<QString> availableESPs;
- for (std::vector<ESPInfo>::const_iterator iter = m_ESPs.begin(); iter != m_ESPs.end(); ++iter) {
- availableESPs.insert(iter->m_Name.toLower());
- }
-
- m_ESPLoadOrder.clear();
-
- int priority = 0;
-
- QStringList primaryPlugins = m_GamePlugin->primaryPlugins();
- for (const QString &plugin : primaryPlugins) {
- if (availableESPs.find(plugin) != availableESPs.end()) {
- m_ESPLoadOrder[plugin] = priority++;
- }
- }
-
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly)) {
- return false;
- }
- if (file.size() == 0) {
- // MO stores at least a header in the file. if it's completely empty the file is broken
- return false;
- }
- while (!file.atEnd()) {
- QByteArray line = file.readLine().trimmed();
- QString modName;
- if ((line.size() > 0) && (line.at(0) != '#')) {
- modName = QString::fromUtf8(line.constData()).toLower();
- }
-
- if ((modName.size() > 0) &&
- (m_ESPLoadOrder.find(modName) == m_ESPLoadOrder.end()) &&
- (availableESPs.find(modName) != availableESPs.end())) {
- m_ESPLoadOrder[modName] = priority++;
- }
- }
-
- file.close();
- return true;
-}
-
-
-void PluginList::readEnabledFrom(const QString &fileName)
-{
- for (std::vector<ESPInfo>::iterator iter = m_ESPs.begin(); iter != m_ESPs.end(); ++iter) {
- if (!iter->m_ForceEnabled) {
- iter->m_Enabled = false;
- }
- iter->m_LoadOrder = -1;
- }
-
- QFile file(fileName);
- if (!file.exists()) {
- throw std::runtime_error(QObject::tr("failed to find \"%1\"").arg(fileName).toUtf8().constData());
- }
-
- file.open(QIODevice::ReadOnly);
- while (!file.atEnd()) {
- QByteArray line = file.readLine();
- QString modName;
- if ((line.size() > 0) && (line.at(0) != '#')) {
- modName = m_LocalCodec->toUnicode(line.trimmed().constData());
- }
- if (modName.size() > 0) {
- std::map<QString, int>::iterator iter = m_ESPsByName.find(modName.toLower());
- if (iter != m_ESPsByName.end()) {
- m_ESPs[iter->second].m_Enabled = true;
- } else {
- qWarning("plugin %s not found", modName.toUtf8().constData());
- emit writePluginsList();
- }
- }
- }
-
- file.close();
-
- testMasters();
-}
-
-
void PluginList::readLockedOrderFrom(const QString &fileName)
{
m_LockedOrder.clear();
@@ -410,53 +286,6 @@ void PluginList::readLockedOrderFrom(const QString &fileName)
file.close();
}
-
-
-void PluginList::writePlugins(const QString &fileName, bool writeUnchecked) const
-{
- SafeWriteFile file(fileName);
-
- QTextCodec *textCodec = writeUnchecked ? m_Utf8Codec : m_LocalCodec;
-
- file->resize(0);
-
- file->write(textCodec->fromUnicode("# This file was automatically generated by Mod Organizer.\r\n"));
-
- QStringList saveList;
-
- bool invalidFileNames = false;
- int writtenCount = 0;
- for (size_t i = 0; i < m_ESPs.size(); ++i) {
- int priority = m_ESPsByPriority[i];
- if (m_ESPs[priority].m_Enabled || writeUnchecked) {
- //file.write(m_ESPs[priority].m_Name.toUtf8());
- if (!textCodec->canEncode(m_ESPs[priority].m_Name)) {
- invalidFileNames = true;
- qCritical("invalid plugin name %s", m_ESPs[priority].m_Name.toUtf8().constData());
- } else {
- saveList << m_ESPs[priority].m_Name;
- file->write(textCodec->fromUnicode(m_ESPs[priority].m_Name));
- }
- file->write("\r\n");
- ++writtenCount;
- }
- }
-
- if (invalidFileNames) {
- reportError(tr("Some of your plugins have invalid names! These plugins can not be loaded by the game. "
- "Please see mo_interface.log for a list of affected plugins and rename them."));
- }
-
- if (writtenCount == 0) {
- qWarning("plugin list would be empty, this is almost certainly wrong. Not saving.");
- } else {
- if (file.commitIfDifferent(m_LastSaveHash[fileName])) {
- qDebug("%s saved", QDir::toNativeSeparators(fileName).toUtf8().constData());
- }
- }
-}
-
-
void PluginList::writeLockedOrder(const QString &fileName) const
{
SafeWriteFile file(fileName);
@@ -471,14 +300,13 @@ void PluginList::writeLockedOrder(const QString &fileName) const
}
-void PluginList::saveTo(const QString &pluginFileName
- , const QString &loadOrderFileName
- , const QString &lockedOrderFileName
+void PluginList::saveTo(const QString &lockedOrderFileName
, const QString& deleterFileName
, bool hideUnchecked) const
{
- writePlugins(pluginFileName, false);
- writePlugins(loadOrderFileName, true);
+ GamePlugins *gamePlugins = m_GamePlugin->feature<GamePlugins>();
+ gamePlugins->writePluginLists(this);
+
writeLockedOrder(lockedOrderFileName);
if (hideUnchecked) {
@@ -552,7 +380,7 @@ bool PluginList::saveLoadOrder(DirectoryEntry &directoryStructure)
int PluginList::enabledCount() const
{
int enabled = 0;
- foreach (auto info, m_ESPs) {
+ for (const auto &info : m_ESPs) {
if (info.m_Enabled) {
++enabled;
}
@@ -606,7 +434,7 @@ void PluginList::refreshLoadOrder()
bool savePluginsList = false;
// this is guaranteed to iterate from lowest key (load order) to highest
for (auto iter = lockedLoadOrder.begin(); iter != lockedLoadOrder.end(); ++iter) {
- auto nameIter = m_ESPsByName.find(iter->second);
+ auto nameIter = m_ESPsByName.find(iter->second.toLower());
if (nameIter != m_ESPsByName.end()) {
// locked esp exists
@@ -641,6 +469,17 @@ void PluginList::disconnectSlots() {
m_PluginStateChanged.disconnect_all_slots();
}
+QStringList PluginList::pluginNames() const
+{
+ QStringList result;
+
+ for (const ESPInfo &info : m_ESPs) {
+ result.append(info.m_Name);
+ }
+
+ return result;
+}
+
IPluginList::PluginStates PluginList::state(const QString &name) const
{
auto iter = m_ESPsByName.find(name.toLower());
@@ -651,6 +490,36 @@ IPluginList::PluginStates PluginList::state(const QString &name) const
}
}
+void PluginList::setState(const QString &name, PluginStates state)
+{
+ auto iter = m_ESPsByName.find(name.toLower());
+ if (iter != m_ESPsByName.end()) {
+ m_ESPs[iter->second].m_Enabled = state == IPluginList::STATE_ACTIVE;
+ }
+}
+
+void PluginList::setLoadOrder(const QStringList &pluginList)
+{
+ for (ESPInfo &info : m_ESPs) {
+ info.m_Priority = -1;
+ }
+ int maxPriority = 0;
+ for (const QString &plugin : pluginList) {
+ auto iter = m_ESPsByName.find(plugin.toLower());
+ if (iter !=m_ESPsByName.end()) {
+ m_ESPs[iter->second].m_Priority = maxPriority++;
+ }
+ }
+
+ // use old priorities
+ for (ESPInfo &info : m_ESPs) {
+ if (info.m_Priority == -1) {
+ info.m_Priority = maxPriority++;
+ }
+ }
+ updateIndices();
+}
+
int PluginList::priority(const QString &name) const
{
auto iter = m_ESPsByName.find(name.toLower());
@@ -688,7 +557,7 @@ QStringList PluginList::masters(const QString &name) const
return QStringList();
} else {
QStringList result;
- foreach (const QString &master, m_ESPs[iter->second].m_Masters) {
+ for (const QString &master : m_ESPs[iter->second].m_Masters) {
result.append(master);
}
return result;
@@ -730,10 +599,16 @@ void PluginList::updateIndices()
m_ESPsByName.clear();
m_ESPsByPriority.clear();
m_ESPsByPriority.resize(m_ESPs.size());
-
for (unsigned int i = 0; i < m_ESPs.size(); ++i) {
+ if (m_ESPs[i].m_Priority < 0) {
+ continue;
+ }
+ if (m_ESPs[i].m_Priority >= static_cast<int>(m_ESPs.size())) {
+ qCritical("invalid priority %d", m_ESPs[i].m_Priority);
+ continue;
+ }
m_ESPsByName[m_ESPs[i].m_Name.toLower()] = i;
- m_ESPsByPriority[m_ESPs[i].m_Priority] = i;
+ m_ESPsByPriority.at(static_cast<size_t>(m_ESPs[i].m_Priority)) = i;
}
}
@@ -741,7 +616,7 @@ void PluginList::updateIndices()
int PluginList::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid()) {
- return m_ESPs.size();
+ return static_cast<int>(m_ESPs.size());
} else {
return 0;
}
@@ -926,7 +801,9 @@ bool PluginList::setData(const QModelIndex &modIndex, const QVariant &value, int
try {
m_PluginStateChanged(modName, newState);
testMasters();
- emit dataChanged(this->index(0, 0), this->index(m_ESPs.size(), columnCount()));
+ emit dataChanged(
+ this->index(0, 0),
+ this->index(static_cast<int>(m_ESPs.size()), columnCount()));
} catch (const std::exception &e) {
qCritical("failed to invoke state changed notification: %s", e.what());
} catch (...) {
@@ -1002,8 +879,10 @@ void PluginList::setPluginPriority(int row, int &newPriority)
}
// enforce valid range
- if (newPriorityTemp < 0) newPriorityTemp = 0;
- else if (newPriorityTemp >= static_cast<int>(m_ESPsByPriority.size())) newPriorityTemp = m_ESPsByPriority.size() - 1;
+ if (newPriorityTemp < 0)
+ newPriorityTemp = 0;
+ else if (newPriorityTemp >= static_cast<int>(m_ESPsByPriority.size()))
+ newPriorityTemp = static_cast<int>(m_ESPsByPriority.size()) - 1;
try {
int oldPriority = m_ESPs.at(row).m_Priority;
@@ -1089,7 +968,7 @@ bool PluginList::dropMimeData(const QMimeData *mimeData, Qt::DropAction action,
if ((row < 0) ||
(row >= static_cast<int>(m_ESPs.size()))) {
- newPriority = m_ESPs.size();
+ newPriority = static_cast<int>(m_ESPs.size());
} else {
newPriority = m_ESPs[row].m_Priority;
}
@@ -1210,7 +1089,7 @@ PluginList::ESPInfo::ESPInfo(const QString &name, bool enabled,
}
}
-void PluginList::managedGameChanged(IPluginGame const *gamePlugin)
+void PluginList::managedGameChanged(const IPluginGame *gamePlugin)
{
m_GamePlugin = gamePlugin;
}
diff --git a/src/pluginlist.h b/src/pluginlist.h
index 9fe6eeac..2c2ba295 100644
--- a/src/pluginlist.h
+++ b/src/pluginlist.h
@@ -110,15 +110,11 @@ public:
*
* @param profileName name of the current profile
* @param baseDirectory the root directory structure representing the virtual data directory
- * @param pluginsFile file that stores the list of enabled plugins
- * @param loadOrderFile file that stored the load order (not an official file but used by many tools for skyrim)
* @param lockedOrderFile list of plugins that shouldn't change load order
* @todo the profile is not used? If it was, we should pass the Profile-object instead
**/
void refresh(const QString &profileName
, const MOShared::DirectoryEntry &baseDirectory
- , const QString &pluginsFile
- , const QString &loadOrderFile
, const QString &lockedOrderFile);
/**
@@ -165,25 +161,13 @@ public:
bool isEnabled(int index);
/**
- * @brief update the plugin status (enabled/disabled) from the specified file
- *
- * @param fileName path of the file to load. the filename should be "plugin.txt"
- * @todo it would make sense to move this into the Profile-class
- **/
- void readEnabledFrom(const QString &fileName);
-
- /**
* @brief save the plugin status to the specified file
*
- * @param pluginFileName path of the plugin.txt to write to
- * @param loadOrderFileName path of the loadorder.txt to write to
* @param lockedOrderFileName path of the lockedorder.txt to write to
* @param deleterFileName file to receive a list of files to hide from the virtual data tree. This is used to hide unchecked plugins if "hideUnchecked" is true
* @param hideUnchecked if true, plugins that aren't enabled will be hidden from the virtual data directory
**/
- void saveTo(const QString &pluginFileName
- , const QString &loadOrderFileName
- , const QString &lockedOrderFileName
+ void saveTo(const QString &lockedOrderFileName
, const QString &deleterFileName
, bool hideUnchecked) const;
@@ -222,13 +206,16 @@ public:
public:
+ virtual QStringList pluginNames() const override;
virtual PluginStates state(const QString &name) const;
+ virtual void setState(const QString &name, PluginStates state) override;
virtual int priority(const QString &name) const;
virtual int loadOrder(const QString &name) const;
+ virtual bool onRefreshed(const std::function<void()> &callback);
virtual bool isMaster(const QString &name) const;
virtual QStringList masters(const QString &name) const;
virtual QString origin(const QString &name) const;
- virtual bool onRefreshed(const std::function<void()> &callback);
+ virtual void setLoadOrder(const QStringList &pluginList) override;
virtual bool onPluginMoved(const std::function<void (const QString &, int, int)> &func);
virtual bool onPluginStateChanged(const std::function<void (const QString &, PluginStates)> &func) override;
@@ -309,10 +296,8 @@ private:
void syncLoadOrder();
void updateIndices();
- void writePlugins(const QString &fileName, bool writeUnchecked) const;
void writeLockedOrder(const QString &fileName) const;
- bool readLoadOrder(const QString &fileName);
void readLockedOrderFrom(const QString &fileName);
void setPluginPriority(int row, int &newPriority);
void changePluginPriority(std::vector<int> rows, int newPriority);
@@ -327,10 +312,6 @@ private:
std::map<QString, int> m_ESPsByName;
std::vector<int> m_ESPsByPriority;
- // maps esp names to the priority specified in loadorder.txt. The esp names are
- // all lowercase!! This is to work around the fact that BOSS for some reason writes some file with
- // capitalization that doesn't match the actual name
- std::map<QString, int> m_ESPLoadOrder;
std::map<QString, int> m_LockedOrder;
std::map<QString, AdditionalInfo> m_AdditionalInfo; // maps esp names to boss information
@@ -338,16 +319,13 @@ private:
QString m_CurrentProfile;
QFontMetrics m_FontMetrics;
- QTextCodec *m_Utf8Codec;
- QTextCodec *m_LocalCodec;
-
SignalRefreshed m_Refreshed;
SignalPluginMoved m_PluginMoved;
SignalPluginStateChanged m_PluginStateChanged;
QTemporaryFile m_TempFile;
- MOBase::IPluginGame const *m_GamePlugin;
+ const MOBase::IPluginGame *m_GamePlugin;
};
diff --git a/src/profile.cpp b/src/profile.cpp
index f4aab46b..8cc60cc0 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -20,13 +20,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "profile.h"
#include "modinfo.h"
-#include "safewritefile.h"
#include "settings.h"
#include <utility.h>
#include <error_report.h>
#include "appconfig.h"
#include <iplugingame.h>
#include <report.h>
+#include <safewritefile.h>
#include <bsainvalidation.h>
#include <dataarchives.h>
diff --git a/src/safewritefile.cpp b/src/safewritefile.cpp
deleted file mode 100644
index 007b3da9..00000000
--- a/src/safewritefile.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-Copyright (C) 2014 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#include "safewritefile.h"
-#include <QStringList>
-#include <QCryptographicHash>
-
-
-using namespace MOBase;
-
-
-SafeWriteFile::SafeWriteFile(const QString &fileName)
-: m_FileName(fileName)
-{
- if (!m_TempFile.open()) {
- throw MyException(QObject::tr("failed to open temporary file"));
- }
-}
-
-
-QFile *SafeWriteFile::operator->() {
- Q_ASSERT(m_TempFile.isOpen());
- return &m_TempFile;
-}
-
-
-void SafeWriteFile::commit() {
- shellDeleteQuiet(m_FileName);
- m_TempFile.rename(m_FileName);
- m_TempFile.setAutoRemove(false);
- m_TempFile.close();
-}
-
-bool SafeWriteFile::commitIfDifferent(QByteArray &inHash) {
- QByteArray newHash = hash();
- if (newHash != inHash
- || !QFile::exists(m_FileName)) {
- commit();
- inHash = newHash;
- return true;
- } else {
- return false;
- }
-}
-
-QByteArray SafeWriteFile::hash()
-{
-
- qint64 pos = m_TempFile.pos();
- m_TempFile.seek(0);
- QByteArray data = m_TempFile.readAll();
- m_TempFile.seek(pos);
- return QCryptographicHash::hash(data, QCryptographicHash::Md5);
-}
diff --git a/src/safewritefile.h b/src/safewritefile.h
deleted file mode 100644
index 0af6bf98..00000000
--- a/src/safewritefile.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright (C) 2014 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#ifndef SAFEWRITEFILE_H
-#define SAFEWRITEFILE_H
-
-
-#include <utility.h>
-#include <QTemporaryFile>
-#include <QString>
-
-/**
- * @brief a wrapper for QFile that ensures the file is only actually (over-)written if writing was successful
- */
-class SafeWriteFile {
-public:
- SafeWriteFile(const QString &fileName);
-
- QFile *operator->();
-
- void commit();
-
- bool commitIfDifferent(QByteArray &hash);
-
-private:
-
- QByteArray hash();
-
-private:
- QString m_FileName;
- QTemporaryFile m_TempFile;
-};
-
-
-#endif // SAFEWRITEFILE_H
-
-
-
-
-