mirror of https://github.com/aria2/aria2
Look for USERPROFILE and the combination of HOMEDRIVE and HOMEPATH to
get user's home directory in MinGW32 build. Usually HOME environment variable is defined in *nix like OSes, but not in Windows. So in MinGW32 build, if HOME is not defined, we also look for USERPROFILE and the combination of HOMEDRIVE and HOMEPATH.pull/1/head
parent
22a6ec6a15
commit
eb6a811279
16
src/util.cc
16
src/util.cc
|
@ -986,6 +986,22 @@ std::string getHomeDir()
|
||||||
if(p) {
|
if(p) {
|
||||||
return p;
|
return p;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
p = getenv("USERPROFILE");
|
||||||
|
if(p) {
|
||||||
|
return p;
|
||||||
|
} else {
|
||||||
|
p = getenv("HOMEDRIVE");
|
||||||
|
if(p) {
|
||||||
|
std::string homeDir = p;
|
||||||
|
p = getenv("HOMEPATH");
|
||||||
|
if(p) {
|
||||||
|
homeDir += p;
|
||||||
|
return homeDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return A2STR::NIL;
|
return A2STR::NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue