FreeEMS Issues - EMStudio
View Issue Details
0000746EMStudioGeneralpublic2012-10-16 15:452012-11-06 18:48
Fred 
Fred 
normalminoralways
resolvedfixed 
AllAllAll
0.0.1-SNAPSHOT 
0.0.10.0.1-SNAPSHOT 
Improvement
0000746: Better file handling for configuration
See parent 0000744
No tags attached.
child of 0000744assigned malcom2073 Better file handling 

Notes
(0002348)
Fred   
2012-10-16 15:47   
This entails getting the correct directories on all OS variants. Sean may have some insight for you as he worked on this a bit.
(0002349)
Fred   
2012-10-16 15:48   
(edited on: 2012-10-16 15:49)
It also means having a config dir ~/.EMStudio/ on *nix (and mac for now, but different later), and ? on Win, Ben and Hentai can confirm this ? value. And a config file inside it, same format for all three, that then points to other dirs. This is likely partly done already.

(0002352)
sean94z   
2012-10-16 15:56   
(edited on: 2012-10-16 15:59)
This is the QSettings code that I came up with based on forum discussion:

    /* restore settings */
// QSettings settings("FreeEMS", "Loader");
#ifdef __WIN32__
        QString appDataDir = getenv("AppData");
        m_autoRipDirectory = appDataDir;
        m_autoRipDirectory += "\\FreeEMS-Loader\\";
        appDataDir = m_autoRipDirectory;
        if (!QDir(appDataDir).exists(appDataDir))
            QDir(appDataDir).mkpath(appDataDir);
        appDataDir += "settings\\";
        if (!QDir(appDataDir).exists(appDataDir))
            QDir(appDataDir).mkpath(appDataDir);
        m_autoRipDirectory += "rips\\";
        if (!QDir(m_autoRipDirectory).exists(m_autoRipDirectory))
            QDir(m_autoRipDirectory).mkpath(m_autoRipDirectory);
#else
        appDataDir = getenv("HOME");
        m_autoRipDirectory = appDataDir;
        appDataDir += "/.FreeEMS-Loader/";
        m_autoRipDirectory += "/FreeEMS-Loader/";
        if (!QDir(appDataDir).exists(appDataDir))
            QDir(appDataDir).mkpath(appDataDir);
        appDataDir += "settings/";
        if (!QDir(appDataDir).exists(appDataDir))
            QDir(appDataDir).mkpath(appDataDir);
        if (!QDir(m_autoRipDirectory).exists(m_autoRipDirectory))
            QDir(m_autoRipDirectory).mkpath(m_autoRipDirectory);
        m_autoRipDirectory += "rips/";
        if (!QDir(m_autoRipDirectory).exists(m_autoRipDirectory))
            QDir(m_autoRipDirectory).mkpath(m_autoRipDirectory);
#endif
    settingsFile = appDataDir + "settings.ini";
    qDebug() << "settings file is -> " << settingsFile;
    QSettings loaderSettings(settingsFile, QSettings::IniFormat);

    /* initialize file and dir locations */
    if (loaderSettings.value("autoRipDirectory").isNull()) {
        displayMessage(MESSAGE_INFO, "This appears to be the first time FreeEMS Loader has been "
                "run on this host, initializing settings..");
I'll keep a close eye on this :)

(0002355)
BenFenner   
2012-10-16 16:19   
Windows should be:

%appdata%\EMStudio\EMStudio-config.json
(0002356)
BenFenner   
2012-10-16 16:19   
Fred says Mac and Linux should be:

~/.EMStudio/EMStudio-config.json
(0002357)
Fred   
2012-10-16 16:31   
Mac only temporarily, so for now it should go:

if (win) {} else {/*the rest*/}
(0002380)
malcom2073   
2012-11-06 18:48   
Done in bf8560eb3211d7b32f5a7581860a30267c28067d