Re-enabled the disabled expand_path routine.

This commit is contained in:
John Wiegley 2008-08-17 05:18:25 -04:00
parent a1db45dca1
commit b89fcfb54a

View file

@ -656,13 +656,11 @@ path expand_path(const path& pathname)
if (pathname.empty()) if (pathname.empty())
return pathname; return pathname;
#if 0 std::string path_string = pathname.string();
// jww (2007-04-30): I need to port this code to use
// boost::filesystem::path
const char * pfx = NULL; const char * pfx = NULL;
string::size_type pos = pathname.find_first_of('/'); string::size_type pos = path_string.find_first_of('/');
if (pathname.length() == 1 || pos == 1) { if (path_string.length() == 1 || pos == 1) {
pfx = std::getenv("HOME"); pfx = std::getenv("HOME");
#ifdef HAVE_GETPWUID #ifdef HAVE_GETPWUID
if (! pfx) { if (! pfx) {
@ -675,7 +673,7 @@ path expand_path(const path& pathname)
} }
#ifdef HAVE_GETPWNAM #ifdef HAVE_GETPWNAM
else { else {
string user(pathname, 1, pos == string::npos ? string user(path_string, 1, pos == string::npos ?
string::npos : pos - 1); string::npos : pos - 1);
struct passwd * pw = getpwnam(user.c_str()); struct passwd * pw = getpwnam(user.c_str());
if (pw) if (pw)
@ -696,12 +694,9 @@ path expand_path(const path& pathname)
if (result.length() == 0 || result[result.length() - 1] != '/') if (result.length() == 0 || result[result.length() - 1] != '/')
result += '/'; result += '/';
result += pathname.substr(pos + 1); result += path_string.substr(pos + 1);
return result; return result;
#else
return pathname;
#endif
} }
path resolve_path(const path& pathname) path resolve_path(const path& pathname)