#include "functions.hh"
#include "exceptions.hh"
#include <QDir>
#include <QDebug>

void createApplicationDirectory(QString name)
{
    QDir home = QDir::home();

    if (!home.exists(name)) {
        if (!home.mkdir(name)) {
            QString errorMessage =
                QObject::tr("Can not create application directory: ")
                + home.filePath(name);
            throw StorageException(errorMessage.toStdString());
        }
    }
}

QString absoluteFileName(QString fileName, QString appDirName)
{
    QDir home = QDir::home();
    QDir appDir(home.absoluteFilePath(appDirName));
    return appDir.absoluteFilePath(fileName);
}
