コード例 #1
0
ファイル: PlasmaSum.cpp プロジェクト: GPNMilano/libhsplasma
plString cdUp(plString path) {
    // Check for root paths, we can't go up from there!
#ifdef WIN32
    if (path.mid(1) == ":\\")
        return path;
#else
    if (path == "/")
        return path;
#endif

    // Not very robust, but it works for one level of parent scanning
    if (path.empty())
        return ".." PATHSEPSTR;

    // Strip the ending slash, if necessary, and then go up one dir
    if (path[path.len()-1] == PATHSEP)
        path = path.left(path.len() - 1);
    plString up = path.beforeLast(PATHSEP);
    if (path[0] == PATHSEP) {
        // Absolute path specified -- make sure we keep it that way
        return up + PATHSEP;
    } else {
        // Relative path specified
        return up.empty() ? "" : up + PATHSEP;
    }
}