close #257
This commit is contained in:
parent
0eadc5af47
commit
7ee67da613
@ -169,6 +169,22 @@ QString GuhSettings::logPath()
|
|||||||
return logPath;
|
return logPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString GuhSettings::settingsPath()
|
||||||
|
{
|
||||||
|
QString path;
|
||||||
|
QString organisationName = QCoreApplication::instance()->organizationName();
|
||||||
|
|
||||||
|
if (organisationName == "guh-test") {
|
||||||
|
path = "/tmp/" + organisationName;
|
||||||
|
} else if (GuhSettings::isRoot()) {
|
||||||
|
path = "/etc/guh/";
|
||||||
|
} else {
|
||||||
|
path = QDir::homePath() + "/.config/" + organisationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns the path where the log file (console log) will be stored. */
|
/*! Returns the path where the log file (console log) will be stored. */
|
||||||
QString GuhSettings::consoleLogPath()
|
QString GuhSettings::consoleLogPath()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -47,6 +47,7 @@ public:
|
|||||||
|
|
||||||
static bool isRoot();
|
static bool isRoot();
|
||||||
static QString logPath();
|
static QString logPath();
|
||||||
|
static QString settingsPath();
|
||||||
static QString consoleLogPath();
|
static QString consoleLogPath();
|
||||||
|
|
||||||
// forwarded QSettings methods
|
// forwarded QSettings methods
|
||||||
|
|||||||
@ -186,6 +186,12 @@ int main(int argc, char *argv[])
|
|||||||
// inform about userid
|
// inform about userid
|
||||||
int userId = getuid();
|
int userId = getuid();
|
||||||
if (userId != 0) {
|
if (userId != 0) {
|
||||||
|
// check if config directory for logfile exists
|
||||||
|
if (!QDir().mkpath(GuhSettings::settingsPath())) {
|
||||||
|
fprintf(stdout, "Could not create guh settings directory %s", qPrintable(GuhSettings::settingsPath()));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
qCDebug(dcApplication) << "=====================================";
|
qCDebug(dcApplication) << "=====================================";
|
||||||
qCDebug(dcApplication) << "guhd" << GUH_VERSION_STRING << "started with user ID" << userId;
|
qCDebug(dcApplication) << "guhd" << GUH_VERSION_STRING << "started with user ID" << userId;
|
||||||
qCDebug(dcApplication) << "=====================================";
|
qCDebug(dcApplication) << "=====================================";
|
||||||
|
|||||||
Reference in New Issue
Block a user