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

@@ -53,13 +53,13 @@ std::string PathImpl::currentImpl()
{
Buffer<wchar_t> buffer(len);
DWORD n = GetCurrentDirectoryW(len, buffer.begin());
if (n > 0 && n <= len)
{
UnicodeConverter::toUTF8(buffer.begin(), result);
if (result[n - 1] != '\\')
result.append("\\");
return result;
}
if (n > 0 && n <= len)
{
UnicodeConverter::toUTF8(buffer.begin(), result);
if (result[result.size() - 1] != '\\')
result.append("\\");
return result;
}
}
throw SystemException("Cannot get current directory");
}
@@ -79,16 +79,18 @@ std::string PathImpl::homeImpl()
std::string PathImpl::tempImpl()
{
Buffer<wchar_t> buffer(MAX_PATH_LEN);
DWORD n = GetTempPathW(static_cast<DWORD>(buffer.size()), buffer.begin());
if (n > 0)
{
std::string result;
UnicodeConverter::toUTF8(buffer.begin(), result);
if (result[n - 1] != '\\')
result.append("\\");
return result;
}
throw SystemException("Cannot get current directory");
DWORD n = GetTempPathW(static_cast<DWORD>(buffer.size()), buffer.begin());
if (n > 0)
{
n = GetLongPathNameW(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
std::string result;
UnicodeConverter::toUTF8(buffer.begin(), result);
if (result[result.size() - 1] != '\\')
result.append("\\");
return result;
}
throw SystemException("Cannot get temporary directory path");
}