EmulationStation/core/src/platform.cpp
Aloshi 98120f9ecd Split into subprojects (external, core, es).
Removed relative paths in #includes.
Changed ViewController to a singleton, removing it from the Window class.
2014-06-20 01:40:36 -05:00

37 lines
912 B
C++

#include "platform.h"
#include <stdlib.h>
#include <boost/filesystem.hpp>
#include <iostream>
std::string getHomePath()
{
std::string homePath;
// this should give you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows
const char * envHome = getenv("HOME");
if(envHome != nullptr)
{
homePath = envHome;
}
#ifdef WIN32
// but does not seem to work for Windows XP or Vista, so try something else
if (homePath.empty()) {
const char * envDir = getenv("HOMEDRIVE");
const char * envPath = getenv("HOMEPATH");
if (envDir != nullptr && envPath != nullptr) {
homePath = envDir;
homePath += envPath;
for(unsigned int i = 0; i < homePath.length(); i++)
if(homePath[i] == '\\')
homePath[i] = '/';
}
}
#endif
// convert path to generic directory seperators
boost::filesystem::path genericPath(homePath);
return genericPath.generic_string();
}