logic: file paths

Changed relative file paths for resources to absolute paths to ensure functionality of shortcuts and file associations on windows platform
This commit is contained in:
Manuel Dobusch
2016-01-26 15:28:43 +01:00
parent e0d7f1d613
commit 8d6220dafb
39 changed files with 291 additions and 84 deletions
+54
View File
@@ -0,0 +1,54 @@
#include "AppPath.h"
#include <string>
std::string AppPath::m_appPath = "";
std::string AppPath::getAppPath()
{
if (m_appPath.length() <= 0)
{
setupAppPath();
}
return m_appPath;
}
void AppPath::setupAppPath()
{
#ifdef _WIN32
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
std::wstring wPath(path);
m_appPath = std::string(wPath.begin(), wPath.end());
size_t pos = m_appPath.find_last_of("/");
if (pos == std::string::npos)
{
pos = m_appPath.find_last_of("\\");
}
if (pos != std::string::npos)
{
m_appPath = m_appPath.substr(0, pos + 1);
}
#elif _WIN64
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
std::wstring wPath(path);
m_appPath = std::string(wPath.begin(), wPath.end());
size_t pos = m_appPath.find_last_of("/");
if (pos == std::string::npos)
{
pos = m_appPath.find_last_of("\\");
}
if (pos != std::string::npos)
{
m_appPath = m_appPath.substr(0, pos + 1);
}
#endif // WINDOWS
}
+30
View File
@@ -0,0 +1,30 @@
#ifndef APP_PATH_H
#define APP_PATH_H
#include <string>
// #include "src\lib_gui\includes.h"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#elif _WIN64
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#endif // WINDOWS
class AppPath
{
public:
static std::string getAppPath();
private:
static void setupAppPath();
static std::string m_appPath;
};
#endif // APP_PATH_H
+22
View File
@@ -0,0 +1,22 @@
#include "ResourcePaths.h"
#include "AppPath.h"
std::string ResourcePaths::m_colorSchemesPath = AppPath::getAppPath() + "data/color_schemes/";
std::string ResourcePaths::m_fontsPath = AppPath::getAppPath() + "data/fonts/";
std::string ResourcePaths::m_guiPath = AppPath::getAppPath() + "data/gui/";
std::string ResourcePaths::getColorSchemesPath()
{
return m_colorSchemesPath;
}
std::string ResourcePaths::getFontsPath()
{
return m_fontsPath;
}
std::string ResourcePaths::getGuiPath()
{
return m_guiPath;
}
+19
View File
@@ -0,0 +1,19 @@
#ifndef RESOURCE_PATHS_H
#define RESOURCE_PATHS_H
#include <string>
class ResourcePaths
{
public:
static std::string getColorSchemesPath();
static std::string getFontsPath();
static std::string getGuiPath();
private:
static std::string m_colorSchemesPath;
static std::string m_fontsPath;
static std::string m_guiPath;
};
#endif // RESOURCE_PATHS_H