trunk/branch integration: Path::popFrontDirectory()

This commit is contained in:
Marian Krivos
2011-08-23 06:57:44 +00:00
parent 6b42ce0d0a
commit df683a59eb
4 changed files with 139 additions and 107 deletions

View File

@@ -44,10 +44,10 @@ namespace Poco {
std::string PathImpl::currentImpl()
{
char buffer[_MAX_PATH];
DWORD n = GetCurrentDirectoryA(sizeof(buffer), buffer);
if (n > 0 && n < sizeof(buffer))
{
char buffer[MAX_PATH];
DWORD n = GetCurrentDirectoryA(sizeof(buffer), buffer);
if (n > 0 && n < sizeof(buffer))
{
std::string result(buffer, n);
if (result[n - 1] != '\\')
result.append("\\");
@@ -70,16 +70,18 @@ std::string PathImpl::homeImpl()
std::string PathImpl::tempImpl()
{
char buffer[_MAX_PATH];
DWORD n = GetTempPathA(sizeof(buffer), 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 current directory");
char buffer[MAX_PATH];
DWORD n = GetTempPathA(sizeof(buffer), buffer);
if (n > 0 && n < sizeof(buffer))
{
n = GetLongPathNameA(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
std::string result(buffer, n);
if (result[n - 1] != '\\')
result.append("\\");
return result;
}
else throw SystemException("Cannot get temporary directory");
}
@@ -91,10 +93,10 @@ std::string PathImpl::nullImpl()
std::string PathImpl::expandImpl(const std::string& path)
{
char buffer[_MAX_PATH];
DWORD n = ExpandEnvironmentStringsA(path.c_str(), buffer, sizeof(buffer));
if (n > 0 && n < sizeof(buffer))
return std::string(buffer, n - 1);
char buffer[MAX_PATH];
DWORD n = ExpandEnvironmentStringsA(path.c_str(), buffer, sizeof(buffer));
if (n > 0 && n < sizeof(buffer))
return std::string(buffer, n - 1);
else
return path;
}