String GetDirectoryPath(const String &path) { String dir = path; if (IsFile(dir)) { int slash_at = dir.FindCharReverse('/'); if (slash_at > 0) dir.ClipMid(slash_at); } return dir; }
void change_to_directory_of_file(String path) { if (Path::IsFile(path)) { int slash_at = path.FindCharReverse('/'); if (slash_at > 0) { path.ClipMid(slash_at); } } if (Path::IsDirectory(path)) { Directory::SetCurrentDirectory(path); } }