More SGPath APIs

This commit is contained in:
James Turner 2016-07-01 17:14:34 +01:00
parent b862cf7e54
commit 32735428bb
2 changed files with 27 additions and 0 deletions

View File

@ -374,6 +374,11 @@ string SGPath::dir() const {
}
}
SGPath SGPath::dirPath() const
{
return SGPath::fromUtf8(dir());
}
// get the base part of the path (everything but the extension.)
string SGPath::base() const
{
@ -871,6 +876,20 @@ std::vector<SGPath> SGPath::pathsFromEnv(const char *name)
//------------------------------------------------------------------------------
std::vector<SGPath> SGPath::pathsFromUtf8(const std::string& paths)
{
std::vector<SGPath> r;
string_list items = sgPathSplit(paths);
string_list_iterator it;
for (it = items.begin(); it != items.end(); ++it) {
r.push_back(SGPath::fromUtf8(it->c_str()));
}
return r;
}
//------------------------------------------------------------------------------
std::vector<SGPath> SGPath::pathsFromLocal8Bit(const std::string& paths)
{
std::vector<SGPath> r;

View File

@ -268,6 +268,12 @@ public:
* or if the destination already exists, or is not writeable
*/
bool rename(const SGPath& newName);
/**
* return the path of the parent directory of this path.
*/
SGPath dirPath() const;
enum StandardLocation
{
@ -311,6 +317,8 @@ public:
static std::vector<SGPath> pathsFromEnv(const char* name);
static std::vector<SGPath> pathsFromUtf8(const std::string& paths);
static std::vector<SGPath> pathsFromLocal8Bit(const std::string& paths);
static std::string join(const std::vector<SGPath>& paths, const std::string& joinWith);