mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 04:17:55 +01:00
GH 30:Poco::Path::home() throws
GH #30: Poco::Path::home() throws when called from Windows Service done for Win32 and Win32U, return root for WinCE
This commit is contained in:
@@ -57,10 +57,36 @@ std::string PathImpl::currentImpl()
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::systemImpl()
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
DWORD n = GetSystemDirectoryA(buffer, sizeof(buffer));
|
||||
if (n > 0 && n < sizeof(buffer))
|
||||
{
|
||||
std::string result(buffer, n);
|
||||
if (result[n - 1] != '\\')
|
||||
result.append("\\");
|
||||
return result;
|
||||
}
|
||||
else throw SystemException("Cannot get system directory");
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::homeImpl()
|
||||
{
|
||||
std::string result = EnvironmentImpl::getImpl("HOMEDRIVE");
|
||||
result.append(EnvironmentImpl::getImpl("HOMEPATH"));
|
||||
std::string result;
|
||||
|
||||
// windows service has no home dir, return system directory instead
|
||||
try
|
||||
{
|
||||
result = EnvironmentImpl::getImpl("HOMEDRIVE");
|
||||
result.append(EnvironmentImpl::getImpl("HOMEPATH"));
|
||||
}
|
||||
catch (NotFoundException&)
|
||||
{
|
||||
result = systemImpl();
|
||||
}
|
||||
|
||||
std::string::size_type n = result.size();
|
||||
if (n > 0 && result[n - 1] != '\\')
|
||||
result.append("\\");
|
||||
|
||||
Reference in New Issue
Block a user