Enhancement - Path, File, Directory integration

- Replaced all access calls.
- Replaced all stat calls.
- Obsoleted util.cpp isAbsoluteDirectory calls.
- Obsoleted util.cpp expandPath calls.
This commit is contained in:
Paul Beckingham 2010-01-16 10:27:31 -05:00
parent 8e47342a18
commit b596e96b43
9 changed files with 66 additions and 120 deletions

View file

@ -341,49 +341,6 @@ const std::string uuid ()
}
#endif
////////////////////////////////////////////////////////////////////////////////
// no i18n
std::string expandPath (const std::string& in)
{
std::string copy = in;
std::string::size_type tilde;
if ((tilde = copy.find ("~/")) != std::string::npos)
{
struct passwd* pw = getpwuid (getuid ());
copy.replace (tilde, 1, pw->pw_dir);
}
else if ((tilde = copy.find ("~")) != std::string::npos)
{
struct passwd* pw = getpwuid (getuid ());
std::string home = pw->pw_dir;
home += "/";
copy.replace (tilde, 1, home);
}
else if ((tilde = copy.find ("~")) != std::string::npos)
{
std::string::size_type slash;
if ((slash = copy.find ("/", tilde)) != std::string::npos)
{
std::string name = copy.substr (tilde + 1, slash - tilde - 1);
struct passwd* pw = getpwnam (name.c_str ());
if (pw)
copy.replace (tilde, slash - tilde, pw->pw_dir);
}
}
return copy;
}
////////////////////////////////////////////////////////////////////////////////
bool isAbsolutePath (const std::string& in)
{
if (in.length () && in[0] == '/')
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
// On Solaris no flock function exists.
#ifdef SOLARIS