MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / getHomePath

Function getHomePath

src/platform.cpp:6–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6std::string getHomePath()
7{
8 std::string homePath;
9
10 //this should give you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows
11 const char * envHome = getenv("HOME");
12 if(envHome != nullptr) {
13 homePath = envHome;
14 }
15#ifdef WIN32
16 //but does not seem to work for Windwos XP or Vista, so try something else
17 if (homePath.empty()) {
18 const char * envDir = getenv("HOMEDRIVE");
19 const char * envPath = getenv("HOMEPATH");
20 if (envDir != nullptr && envPath != nullptr) {
21 homePath = envDir;
22 homePath += envPath;
23
24 for(unsigned int i = 0; i < homePath.length(); i++)
25 if(homePath[i] == '\\')
26 homePath[i] = '/';
27 }
28 }
29#else
30 if (homePath.empty()) {
31 homePath = "~";
32 }
33#endif
34
35 //convert path to generic directory seperators
36 boost::filesystem::path genericPath(homePath);
37 return genericPath.generic_string();
38}

Callers 10

getLogPathMethod · 0.85
SystemDataMethod · 0.85
getConfigPathMethod · 0.85
getGamelistPathMethod · 0.85
saveFileMethod · 0.85
loadFileMethod · 0.85
getConfigPathMethod · 0.85
verifyHomeFolderExistsFunction · 0.85
expandPathMethod · 0.85
getThemeFileMethod · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected