mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 18:45:10 +01:00
fixed #627: Poco::Path::home() returns c:\windows\system32 instead home directory
This commit is contained in:
parent
10aedfe5ad
commit
a5c8b751d9
@ -55,14 +55,16 @@ std::string PathImpl::systemImpl()
|
|||||||
std::string PathImpl::homeImpl()
|
std::string PathImpl::homeImpl()
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH"))
|
||||||
// windows service has no home dir, return system directory instead
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
result = EnvironmentImpl::getImpl("HOMEDRIVE");
|
result = EnvironmentImpl::getImpl("HOMEDRIVE");
|
||||||
result.append(EnvironmentImpl::getImpl("HOMEPATH"));
|
result.append(EnvironmentImpl::getImpl("HOMEPATH"));
|
||||||
}
|
}
|
||||||
catch (NotFoundException&)
|
else if (EnvironmentImpl::hasImpl("USERPROFILE"))
|
||||||
|
{
|
||||||
|
result = EnvironmentImpl::getImpl("USERPROFILE");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result = systemImpl();
|
result = systemImpl();
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,16 @@ std::string PathImpl::systemImpl()
|
|||||||
std::string PathImpl::homeImpl()
|
std::string PathImpl::homeImpl()
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH"))
|
||||||
// windows service has no home dir, return system directory instead
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
result = EnvironmentImpl::getImpl("HOMEDRIVE");
|
result = EnvironmentImpl::getImpl("HOMEDRIVE");
|
||||||
result.append(EnvironmentImpl::getImpl("HOMEPATH"));
|
result.append(EnvironmentImpl::getImpl("HOMEPATH"));
|
||||||
}
|
}
|
||||||
catch (NotFoundException&)
|
else if (EnvironmentImpl::hasImpl("USERPROFILE"))
|
||||||
|
{
|
||||||
|
result = EnvironmentImpl::getImpl("USERPROFILE");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result = systemImpl();
|
result = systemImpl();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user