mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-26 00:40:05 +01:00
trunk/branch integration: Path::popFrontDirectory()
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Path_UNIX.cpp
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/src/Path_UNIX.cpp#2 $
|
||||
// $Id: //poco/1.4/Foundation/src/Path_UNIX.cpp#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@@ -37,11 +37,13 @@
|
||||
#include "Poco/Path_UNIX.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Environment_UNIX.h"
|
||||
#include "Poco/Ascii.h"
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(POCO_VXWORKS)
|
||||
#include <pwd.h>
|
||||
#include <cctype>
|
||||
#endif
|
||||
#include <climits>
|
||||
|
||||
|
||||
@@ -69,9 +71,15 @@ std::string PathImpl::currentImpl()
|
||||
|
||||
std::string PathImpl::homeImpl()
|
||||
{
|
||||
std::string path;
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
if (pwd)
|
||||
#if defined(POCO_VXWORKS)
|
||||
if (EnvironmentImpl::hasImpl("HOME"))
|
||||
return EnvironmentImpl::getImpl("HOME");
|
||||
else
|
||||
return "/";
|
||||
#else
|
||||
std::string path;
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
if (pwd)
|
||||
path = pwd->pw_dir;
|
||||
else
|
||||
{
|
||||
@@ -81,9 +89,10 @@ std::string PathImpl::homeImpl()
|
||||
else
|
||||
path = EnvironmentImpl::getImpl("HOME");
|
||||
}
|
||||
std::string::size_type n = path.size();
|
||||
if (n > 0 && path[n - 1] != '/') path.append("/");
|
||||
return path;
|
||||
std::string::size_type n = path.size();
|
||||
if (n > 0 && path[n - 1] != '/') path.append("/");
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +116,11 @@ std::string PathImpl::tempImpl()
|
||||
|
||||
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;
|
||||
while (it != end && *it != '}') var += *it++;
|
||||
if (it != end) ++it;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (it != end && (std::isalnum(*it) || *it == '_')) var += *it++;
|
||||
}
|
||||
char* val = getenv(var.c_str());
|
||||
if (val) result += val;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (it != end && (Ascii::isAlphaNumeric(*it) || *it == '_')) var += *it++;
|
||||
}
|
||||
char* val = getenv(var.c_str());
|
||||
if (val) result += val;
|
||||
}
|
||||
else result += *it++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user