Changeset 59:009b21134b14 in SMSSender


Ignore:
Timestamp:
Feb 2, 2010 1:06:47 PM (9 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@58
Message:
  • Creating settings path if it does not exist
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/business/BCSettings.cpp

    r56 r59  
    88#include "BCSettings.h"
    99
     10#include <QDir>
    1011#include <QDirIterator>
    1112#include <QFileInfo>
    1213#include <QCoreApplication>
    1314#include <QDesktopServices>
     15#include <QDebug>
    1416
    1517#include "../persistence/PersistenceFactory.h"
     
    2729
    2830QString BCSettings::getSettingsPath(){
    29     if (QFile::exists(qApp->applicationDirPath() + "/data.db")) {
    30         return qApp->applicationDirPath() + "/";
    31     } else {
    32         return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/gorrion/SMSSender/";
     31    QString path = qApp->applicationDirPath() + "/";
     32    qDebug() << "AppDirPath: " + path;
     33    if (!QFile::exists(path + "data.db")) {
     34        path = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/gorrion/SMSSender/";
    3335    }
     36   
     37    path = QDir::toNativeSeparators(path); // Replace / by \ on windows (per example)
     38    QDir dir;
     39    if (!dir.exists(path)) {
     40        dir.mkpath(path); // Create path if not exists
     41    }
     42   
     43    qDebug() << "Using " + path + " as settings path";
     44    return path;
    3445}
    3546
Note: See TracChangeset for help on using the changeset viewer.