| 43 | } |
| 44 | |
| 45 | std::string Path::GetDirectory(const std::string& filepath) |
| 46 | { |
| 47 | std::string path = filepath; |
| 48 | if (path.size() > 1 && path[path.size() - 1] == '/') |
| 49 | path.resize(path.size() - 1); |
| 50 | size_t last_slash = path.rfind('/'); |
| 51 | if (last_slash == std::string::npos) |
| 52 | return "."; |
| 53 | if (last_slash == 0) |
| 54 | return "/"; |
| 55 | |
| 56 | return path.substr(0, last_slash); |
| 57 | } |
| 58 | |
| 59 | std::string Path::ToAbsolute(const std::string& filepath) |
| 60 | { |