mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 00:15:27 +01:00
trunk/branch integration: Path::popFrontDirectory()
This commit is contained in:
parent
6b42ce0d0a
commit
df683a59eb
@ -16,14 +16,14 @@
|
|||||||
// execute, and transmit the Software, and to prepare derivative works of the
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
// Software, and to permit third-parties to whom the Software is furnished to
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
// do so, all subject to the following:
|
// do so, all subject to the following:
|
||||||
//
|
//
|
||||||
// The copyright notices in the Software and this entire statement, including
|
// The copyright notices in the Software and this entire statement, including
|
||||||
// the above license grant, this restriction and the following disclaimer,
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
// must be included in all copies of the Software, in whole or in part, and
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
// all derivative works of the Software, unless such copies or derivative
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
// works are solely in the form of machine-executable object code generated by
|
// works are solely in the form of machine-executable object code generated by
|
||||||
// a source language processor.
|
// a source language processor.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
@ -50,7 +50,11 @@
|
|||||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||||
#include "Path_UNIX.cpp"
|
#include "Path_UNIX.cpp"
|
||||||
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||||
|
#if defined(_WIN32_WCE)
|
||||||
|
#include "Path_WINCE.cpp"
|
||||||
|
#else
|
||||||
#include "Path_WIN32U.cpp"
|
#include "Path_WIN32U.cpp"
|
||||||
|
#endif
|
||||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
#include "Path_WIN32.cpp"
|
#include "Path_WIN32.cpp"
|
||||||
#endif
|
#endif
|
||||||
@ -95,51 +99,51 @@ Path::Path(const char* path, Style style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path::Path(const Path& path):
|
Path::Path(const Path& path):
|
||||||
_node(path._node),
|
_node(path._node),
|
||||||
_device(path._device),
|
_device(path._device),
|
||||||
_name(path._name),
|
_name(path._name),
|
||||||
_version(path._version),
|
_version(path._version),
|
||||||
_dirs(path._dirs),
|
_dirs(path._dirs),
|
||||||
_absolute(path._absolute)
|
_absolute(path._absolute)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path::Path(const Path& parent, const std::string& fileName):
|
Path::Path(const Path& parent, const std::string& fileName):
|
||||||
_node(parent._node),
|
_node(parent._node),
|
||||||
_device(parent._device),
|
_device(parent._device),
|
||||||
_name(parent._name),
|
_name(parent._name),
|
||||||
_version(parent._version),
|
_version(parent._version),
|
||||||
_dirs(parent._dirs),
|
_dirs(parent._dirs),
|
||||||
_absolute(parent._absolute)
|
_absolute(parent._absolute)
|
||||||
{
|
{
|
||||||
makeDirectory();
|
makeDirectory();
|
||||||
_name = fileName;
|
_name = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path::Path(const Path& parent, const char* fileName):
|
Path::Path(const Path& parent, const char* fileName):
|
||||||
_node(parent._node),
|
_node(parent._node),
|
||||||
_device(parent._device),
|
_device(parent._device),
|
||||||
_name(parent._name),
|
_name(parent._name),
|
||||||
_version(parent._version),
|
_version(parent._version),
|
||||||
_dirs(parent._dirs),
|
_dirs(parent._dirs),
|
||||||
_absolute(parent._absolute)
|
_absolute(parent._absolute)
|
||||||
{
|
{
|
||||||
makeDirectory();
|
makeDirectory();
|
||||||
_name = fileName;
|
_name = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path::Path(const Path& parent, const Path& relative):
|
Path::Path(const Path& parent, const Path& relative):
|
||||||
_node(parent._node),
|
_node(parent._node),
|
||||||
_device(parent._device),
|
_device(parent._device),
|
||||||
_name(parent._name),
|
_name(parent._name),
|
||||||
_version(parent._version),
|
_version(parent._version),
|
||||||
_dirs(parent._dirs),
|
_dirs(parent._dirs),
|
||||||
_absolute(parent._absolute)
|
_absolute(parent._absolute)
|
||||||
{
|
{
|
||||||
resolve(relative);
|
resolve(relative);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,13 +152,13 @@ Path::~Path()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path& Path::operator = (const Path& path)
|
Path& Path::operator = (const Path& path)
|
||||||
{
|
{
|
||||||
return assign(path);
|
return assign(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path& Path::operator = (const std::string& path)
|
Path& Path::operator = (const std::string& path)
|
||||||
{
|
{
|
||||||
return assign(path);
|
return assign(path);
|
||||||
@ -206,7 +210,7 @@ Path& Path::assign(const std::string& path)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path& Path::assign(const std::string& path, Style style)
|
Path& Path::assign(const std::string& path, Style style)
|
||||||
{
|
{
|
||||||
switch (style)
|
switch (style)
|
||||||
@ -250,7 +254,7 @@ std::string Path::toString() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Path::toString(Style style) const
|
std::string Path::toString(Style style) const
|
||||||
{
|
{
|
||||||
switch (style)
|
switch (style)
|
||||||
@ -456,36 +460,36 @@ void Path::setNode(const std::string& node)
|
|||||||
_absolute = _absolute || !node.empty();
|
_absolute = _absolute || !node.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Path::setDevice(const std::string& device)
|
void Path::setDevice(const std::string& device)
|
||||||
{
|
{
|
||||||
_device = device;
|
_device = device;
|
||||||
_absolute = _absolute || !device.empty();
|
_absolute = _absolute || !device.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string& Path::directory(int n) const
|
const std::string& Path::directory(int n) const
|
||||||
{
|
{
|
||||||
poco_assert (0 <= n && n <= _dirs.size());
|
poco_assert (0 <= n && n <= _dirs.size());
|
||||||
|
|
||||||
if (n < _dirs.size())
|
if (n < _dirs.size())
|
||||||
return _dirs[n];
|
return _dirs[n];
|
||||||
else
|
else
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string& Path::operator [] (int n) const
|
const std::string& Path::operator [] (int n) const
|
||||||
{
|
{
|
||||||
poco_assert (0 <= n && n <= _dirs.size());
|
poco_assert (0 <= n && n <= _dirs.size());
|
||||||
|
|
||||||
if (n < _dirs.size())
|
if (n < _dirs.size())
|
||||||
return _dirs[n];
|
return _dirs[n];
|
||||||
else
|
else
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Path::pushDirectory(const std::string& dir)
|
void Path::pushDirectory(const std::string& dir)
|
||||||
{
|
{
|
||||||
if (!dir.empty() && dir != ".")
|
if (!dir.empty() && dir != ".")
|
||||||
@ -512,18 +516,27 @@ void Path::pushDirectory(const std::string& dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Path::popDirectory()
|
void Path::popDirectory()
|
||||||
{
|
{
|
||||||
poco_assert (!_dirs.empty());
|
poco_assert (!_dirs.empty());
|
||||||
|
|
||||||
_dirs.pop_back();
|
_dirs.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Path::popFrontDirectory()
|
||||||
|
{
|
||||||
|
poco_assert (!_dirs.empty());
|
||||||
|
|
||||||
|
StringVec::iterator it = _dirs.begin();
|
||||||
|
_dirs.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Path::setFileName(const std::string& name)
|
void Path::setFileName(const std::string& name)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -559,7 +572,7 @@ void Path::setExtension(const std::string& extension)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Path::getExtension() const
|
std::string Path::getExtension() const
|
||||||
{
|
{
|
||||||
std::string::size_type pos = _name.rfind('.');
|
std::string::size_type pos = _name.rfind('.');
|
||||||
@ -586,13 +599,13 @@ std::string Path::current()
|
|||||||
return PathImpl::currentImpl();
|
return PathImpl::currentImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Path::home()
|
std::string Path::home()
|
||||||
{
|
{
|
||||||
return PathImpl::homeImpl();
|
return PathImpl::homeImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Path::temp()
|
std::string Path::temp()
|
||||||
{
|
{
|
||||||
return PathImpl::tempImpl();
|
return PathImpl::tempImpl();
|
||||||
@ -604,7 +617,7 @@ std::string Path::null()
|
|||||||
return PathImpl::nullImpl();
|
return PathImpl::nullImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Path::expand(const std::string& path)
|
std::string Path::expand(const std::string& path)
|
||||||
{
|
{
|
||||||
return PathImpl::expandImpl(path);
|
return PathImpl::expandImpl(path);
|
||||||
@ -652,7 +665,7 @@ void Path::parseUnix(const std::string& path)
|
|||||||
|
|
||||||
if (it != end)
|
if (it != end)
|
||||||
{
|
{
|
||||||
if (*it == '/')
|
if (*it == '/')
|
||||||
{
|
{
|
||||||
_absolute = true; ++it;
|
_absolute = true; ++it;
|
||||||
}
|
}
|
||||||
@ -675,18 +688,20 @@ void Path::parseUnix(const std::string& path)
|
|||||||
if (it != end)
|
if (it != end)
|
||||||
{
|
{
|
||||||
if (_dirs.empty())
|
if (_dirs.empty())
|
||||||
{
|
{
|
||||||
if (!name.empty() && *(name.rbegin()) == ':')
|
if (!name.empty() && *(name.rbegin()) == ':')
|
||||||
{
|
{
|
||||||
_device.assign(name, 0, name.length() - 1);
|
_absolute = true;
|
||||||
_absolute = true;
|
_device.assign(name, 0, name.length() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pushDirectory(name);
|
{
|
||||||
}
|
pushDirectory(name);
|
||||||
else pushDirectory(name);
|
}
|
||||||
}
|
}
|
||||||
else _name = name;
|
else pushDirectory(name);
|
||||||
|
}
|
||||||
|
else _name = name;
|
||||||
if (it != end) ++it;
|
if (it != end) ++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -711,17 +726,17 @@ void Path::parseWindows(const std::string& path)
|
|||||||
}
|
}
|
||||||
else if (it != end)
|
else if (it != end)
|
||||||
{
|
{
|
||||||
char d = *it++;
|
char d = *it++;
|
||||||
if (it != end && *it == ':') // drive letter
|
if (it != end && *it == ':') // drive letter
|
||||||
{
|
{
|
||||||
if (_absolute || !(d >= 'a' && d <= 'z' || d >= 'A' && d <= 'Z')) throw PathSyntaxException(path);
|
if (_absolute || !((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z'))) throw PathSyntaxException(path);
|
||||||
_absolute = true;
|
_absolute = true;
|
||||||
_device += d;
|
_device += d;
|
||||||
++it;
|
++it;
|
||||||
if (it == end || *it != '\\' && *it != '/') throw PathSyntaxException(path);
|
if (it == end || (*it != '\\' && *it != '/')) throw PathSyntaxException(path);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
else --it;
|
else --it;
|
||||||
}
|
}
|
||||||
while (it != end)
|
while (it != end)
|
||||||
{
|
{
|
||||||
@ -780,7 +795,7 @@ void Path::parseVMS(const std::string& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
{
|
{
|
||||||
if (it != end && *it == '[')
|
if (it != end && *it == '[')
|
||||||
@ -806,7 +821,7 @@ void Path::parseVMS(const std::string& path)
|
|||||||
{
|
{
|
||||||
if (_dirs.empty() || _dirs.back() == "..")
|
if (_dirs.empty() || _dirs.back() == "..")
|
||||||
_dirs.push_back("..");
|
_dirs.push_back("..");
|
||||||
else
|
else
|
||||||
_dirs.pop_back();
|
_dirs.pop_back();
|
||||||
}
|
}
|
||||||
else _dirs.push_back(name);
|
else _dirs.push_back(name);
|
||||||
@ -877,7 +892,7 @@ void Path::parseGuess(const std::string& path)
|
|||||||
case '\\': hasBackslash = true; break;
|
case '\\': hasBackslash = true; break;
|
||||||
case '/': hasSlash = true; break;
|
case '/': hasSlash = true; break;
|
||||||
case '[': hasOpenBracket = true;
|
case '[': hasOpenBracket = true;
|
||||||
case ']': hasClosBracket = hasOpenBracket;
|
case ']': hasClosBracket = hasOpenBracket;
|
||||||
case ';': semiIt = it; break;
|
case ';': semiIt = it; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Path_UNIX.cpp
|
// Path_UNIX.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Foundation/src/Path_UNIX.cpp#2 $
|
// $Id: //poco/1.4/Foundation/src/Path_UNIX.cpp#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
@ -37,11 +37,13 @@
|
|||||||
#include "Poco/Path_UNIX.h"
|
#include "Poco/Path_UNIX.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/Environment_UNIX.h"
|
#include "Poco/Environment_UNIX.h"
|
||||||
|
#include "Poco/Ascii.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#if !defined(POCO_VXWORKS)
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <cctype>
|
#endif
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
|
|
||||||
@ -69,9 +71,15 @@ std::string PathImpl::currentImpl()
|
|||||||
|
|
||||||
std::string PathImpl::homeImpl()
|
std::string PathImpl::homeImpl()
|
||||||
{
|
{
|
||||||
std::string path;
|
#if defined(POCO_VXWORKS)
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
if (EnvironmentImpl::hasImpl("HOME"))
|
||||||
if (pwd)
|
return EnvironmentImpl::getImpl("HOME");
|
||||||
|
else
|
||||||
|
return "/";
|
||||||
|
#else
|
||||||
|
std::string path;
|
||||||
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
|
if (pwd)
|
||||||
path = pwd->pw_dir;
|
path = pwd->pw_dir;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -81,9 +89,10 @@ std::string PathImpl::homeImpl()
|
|||||||
else
|
else
|
||||||
path = EnvironmentImpl::getImpl("HOME");
|
path = EnvironmentImpl::getImpl("HOME");
|
||||||
}
|
}
|
||||||
std::string::size_type n = path.size();
|
std::string::size_type n = path.size();
|
||||||
if (n > 0 && path[n - 1] != '/') path.append("/");
|
if (n > 0 && path[n - 1] != '/') path.append("/");
|
||||||
return path;
|
return path;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -107,7 +116,11 @@ std::string PathImpl::tempImpl()
|
|||||||
|
|
||||||
std::string PathImpl::nullImpl()
|
std::string PathImpl::nullImpl()
|
||||||
{
|
{
|
||||||
return "/dev/null";
|
#if defined(POCO_VXWORKS)
|
||||||
|
return "/null";
|
||||||
|
#else
|
||||||
|
return "/dev/null";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,13 +149,13 @@ std::string PathImpl::expandImpl(const std::string& path)
|
|||||||
++it;
|
++it;
|
||||||
while (it != end && *it != '}') var += *it++;
|
while (it != end && *it != '}') var += *it++;
|
||||||
if (it != end) ++it;
|
if (it != end) ++it;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (it != end && (std::isalnum(*it) || *it == '_')) var += *it++;
|
while (it != end && (Ascii::isAlphaNumeric(*it) || *it == '_')) var += *it++;
|
||||||
}
|
}
|
||||||
char* val = getenv(var.c_str());
|
char* val = getenv(var.c_str());
|
||||||
if (val) result += val;
|
if (val) result += val;
|
||||||
}
|
}
|
||||||
else result += *it++;
|
else result += *it++;
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,10 @@ namespace Poco {
|
|||||||
|
|
||||||
std::string PathImpl::currentImpl()
|
std::string PathImpl::currentImpl()
|
||||||
{
|
{
|
||||||
char buffer[_MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
DWORD n = GetCurrentDirectoryA(sizeof(buffer), buffer);
|
DWORD n = GetCurrentDirectoryA(sizeof(buffer), buffer);
|
||||||
if (n > 0 && n < sizeof(buffer))
|
if (n > 0 && n < sizeof(buffer))
|
||||||
{
|
{
|
||||||
std::string result(buffer, n);
|
std::string result(buffer, n);
|
||||||
if (result[n - 1] != '\\')
|
if (result[n - 1] != '\\')
|
||||||
result.append("\\");
|
result.append("\\");
|
||||||
@ -70,16 +70,18 @@ std::string PathImpl::homeImpl()
|
|||||||
|
|
||||||
std::string PathImpl::tempImpl()
|
std::string PathImpl::tempImpl()
|
||||||
{
|
{
|
||||||
char buffer[_MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
DWORD n = GetTempPathA(sizeof(buffer), buffer);
|
DWORD n = GetTempPathA(sizeof(buffer), buffer);
|
||||||
if (n > 0 && n < sizeof(buffer))
|
if (n > 0 && n < sizeof(buffer))
|
||||||
{
|
{
|
||||||
std::string result(buffer, n);
|
n = GetLongPathNameA(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
|
||||||
if (result[n - 1] != '\\')
|
if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
|
||||||
result.append("\\");
|
std::string result(buffer, n);
|
||||||
return result;
|
if (result[n - 1] != '\\')
|
||||||
}
|
result.append("\\");
|
||||||
else throw SystemException("Cannot get current directory");
|
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)
|
std::string PathImpl::expandImpl(const std::string& path)
|
||||||
{
|
{
|
||||||
char buffer[_MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
DWORD n = ExpandEnvironmentStringsA(path.c_str(), buffer, sizeof(buffer));
|
DWORD n = ExpandEnvironmentStringsA(path.c_str(), buffer, sizeof(buffer));
|
||||||
if (n > 0 && n < sizeof(buffer))
|
if (n > 0 && n < sizeof(buffer))
|
||||||
return std::string(buffer, n - 1);
|
return std::string(buffer, n - 1);
|
||||||
else
|
else
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,13 @@ std::string PathImpl::currentImpl()
|
|||||||
{
|
{
|
||||||
Buffer<wchar_t> buffer(len);
|
Buffer<wchar_t> buffer(len);
|
||||||
DWORD n = GetCurrentDirectoryW(len, buffer.begin());
|
DWORD n = GetCurrentDirectoryW(len, buffer.begin());
|
||||||
if (n > 0 && n <= len)
|
if (n > 0 && n <= len)
|
||||||
{
|
{
|
||||||
UnicodeConverter::toUTF8(buffer.begin(), result);
|
UnicodeConverter::toUTF8(buffer.begin(), result);
|
||||||
if (result[n - 1] != '\\')
|
if (result[result.size() - 1] != '\\')
|
||||||
result.append("\\");
|
result.append("\\");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw SystemException("Cannot get current directory");
|
throw SystemException("Cannot get current directory");
|
||||||
}
|
}
|
||||||
@ -79,16 +79,18 @@ std::string PathImpl::homeImpl()
|
|||||||
std::string PathImpl::tempImpl()
|
std::string PathImpl::tempImpl()
|
||||||
{
|
{
|
||||||
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
||||||
DWORD n = GetTempPathW(static_cast<DWORD>(buffer.size()), buffer.begin());
|
DWORD n = GetTempPathW(static_cast<DWORD>(buffer.size()), buffer.begin());
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
std::string result;
|
n = GetLongPathNameW(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
|
||||||
UnicodeConverter::toUTF8(buffer.begin(), result);
|
if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
|
||||||
if (result[n - 1] != '\\')
|
std::string result;
|
||||||
result.append("\\");
|
UnicodeConverter::toUTF8(buffer.begin(), result);
|
||||||
return result;
|
if (result[result.size() - 1] != '\\')
|
||||||
}
|
result.append("\\");
|
||||||
throw SystemException("Cannot get current directory");
|
return result;
|
||||||
|
}
|
||||||
|
throw SystemException("Cannot get temporary directory path");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user