Skip to content

Commit

Permalink
[fingerterm] Create settings path if it doesn't exist. Fixes MER#1618
Browse files Browse the repository at this point in the history
  • Loading branch information
jusa committed Jul 7, 2016
1 parent f18fd22 commit 9024033
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions main.cpp
Expand Up @@ -22,6 +22,8 @@
#include <QtGui>
#include <QtQml>
#include <QQuickView>
#include <QDir>
#include <QString>

extern "C" {
#include <pty.h>
Expand All @@ -38,11 +40,19 @@ extern "C" {
#include "version.h"
#include "keyloader.h"

void copyFileFromResources(QString from, QString to);
static void copyFileFromResources(QString from, QString to);

int main(int argc, char *argv[])
{
QSettings *settings = new QSettings(QDir::homePath()+"/.config/FingerTerm/settings.ini", QSettings::IniFormat);
QString settings_path(QDir::homePath() + "/.config/FingerTerm");
QDir dir;

if (!dir.exists(settings_path)) {
if (!dir.mkdir(settings_path))
qWarning() << "Could not create fingerterm settings path" << settings_path;
}

QSettings *settings = new QSettings(settings_path + "/settings.ini", QSettings::IniFormat);

QCoreApplication::setApplicationName("Fingerterm");

Expand Down Expand Up @@ -174,7 +184,7 @@ int main(int argc, char *argv[])
return app.exec();
}

void copyFileFromResources(QString from, QString to)
static void copyFileFromResources(QString from, QString to)
{
// copy a file from resources to the config dir if it does not exist there
QFileInfo toFile(to);
Expand All @@ -185,7 +195,7 @@ void copyFileFromResources(QString from, QString to)
newToFile.write( reinterpret_cast<const char*>(res.data()) );
newToFile.close();
} else {
qFatal("failed to copy default config from resources");
qWarning() << "Failed to copy default config from resources to" << toFile.filePath();
}
}
}

0 comments on commit 9024033

Please sign in to comment.