#include "path.hpp" #include #include #include namespace cloonel { namespace { ///--------------------------------------------------------------------- ///--------------------------------------------------------------------- std::string GetCleanBasePath (const std::string&& parPath) { const size_t pathlen = parPath.size(); switch (pathlen) { case 0: return std::string("/"); case 1: return parPath; default: if (parPath[pathlen - 1] == '/') return parPath.substr(0, pathlen - 1); else return parPath; } } } //unnamed namespace ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- Path::Path (const char* parBasePath) : m_basePath(GetCleanBasePath(std::string(parBasePath))) { } ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- std::string Path::GetFullPath (const std::string& parPath) const { std::ostringstream oss; oss << m_basePath << '/' << parPath; return oss.str(); } ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- std::string Path::GetFullPath (const char* parPath) const { assert(parPath); std::ostringstream oss; oss << m_basePath << '/' << parPath; return oss.str(); } } // namespace cloonel