Update ServerPathUtils::getDataDirectory to use custom path lookup

This commit is contained in:
Ryan Huffman 2016-01-18 14:22:48 -08:00 committed by Stephen Birarda
parent a27d35566d
commit de36f3eeb2

View file

@ -1,16 +1,37 @@
//
// ServerPathUtils.cpp
// libraries/shared/src
//
// Created by Ryan Huffman on 01/12/16.
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "ServerPathUtils.h"
#include <QStandardPaths>
#include <QtCore/QDir>
#include <QtWidgets/qapplication.h>
#include <QDebug>
QString ServerPathUtils::getDataDirectory() {
auto directory = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (directory.isEmpty()) {
directory = '.';
}
return directory;
auto homeDirectory = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
#ifdef Q_OS_WIN
homeDirectory.cd("AppData/Roaming/");
#elif Q_OS_OSX
homeDirectory.cd("Library/Application Support/");
#else
homeDirectory.cd(".local/share/");
#endif
homeDirectory.cd(qApp->organizationName() + "/" + qApp->applicationName());
return homeDirectory.absolutePath();
}
QString ServerPathUtils::getDataFilePath(QString filename) {
return QDir(getDataDirectory()).absoluteFilePath(filename);
}