From a5c8b751d9038740a6bd7f2b2ede3e3473e84a0d Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 9 Dec 2014 10:38:11 +0100 Subject: [PATCH] fixed #627: Poco::Path::home() returns c:\windows\system32 instead home directory --- Foundation/src/Path_WIN32.cpp | 10 ++++++---- Foundation/src/Path_WIN32U.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Foundation/src/Path_WIN32.cpp b/Foundation/src/Path_WIN32.cpp index 76165821c..259c7c1ab 100644 --- a/Foundation/src/Path_WIN32.cpp +++ b/Foundation/src/Path_WIN32.cpp @@ -55,14 +55,16 @@ std::string PathImpl::systemImpl() std::string PathImpl::homeImpl() { std::string result; - - // windows service has no home dir, return system directory instead - try + if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH")) { result = EnvironmentImpl::getImpl("HOMEDRIVE"); result.append(EnvironmentImpl::getImpl("HOMEPATH")); } - catch (NotFoundException&) + else if (EnvironmentImpl::hasImpl("USERPROFILE")) + { + result = EnvironmentImpl::getImpl("USERPROFILE"); + } + else { result = systemImpl(); } diff --git a/Foundation/src/Path_WIN32U.cpp b/Foundation/src/Path_WIN32U.cpp index 10d2b7fc4..799231717 100644 --- a/Foundation/src/Path_WIN32U.cpp +++ b/Foundation/src/Path_WIN32U.cpp @@ -65,14 +65,16 @@ std::string PathImpl::systemImpl() std::string PathImpl::homeImpl() { std::string result; - - // windows service has no home dir, return system directory instead - try + if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH")) { result = EnvironmentImpl::getImpl("HOMEDRIVE"); result.append(EnvironmentImpl::getImpl("HOMEPATH")); } - catch (NotFoundException&) + else if (EnvironmentImpl::hasImpl("USERPROFILE")) + { + result = EnvironmentImpl::getImpl("USERPROFILE"); + } + else { result = systemImpl(); }