ST::string cdUp(ST::string path) { // Check for root paths, we can't go up from there! #ifdef _WIN32 if (path.substr(1) == ":\\") return path; #else if (path == "/") return path; #endif // Not very robust, but it works for one level of parent scanning if (path.is_empty()) return ".." PATHSEPSTR; // Strip the ending slash, if necessary, and then go up one dir if (path.char_at(path.size()-1) == PATHSEP) path = path.left(path.size() - 1); ST::string up = path.before_last(PATHSEP); if (path.char_at(0) == PATHSEP) { // Absolute path specified -- make sure we keep it that way return up + PATHSEPSTR; } else { // Relative path specified return up.is_empty() ? "" : up + PATHSEPSTR; } }