Fix navigation upwards from a pinned game streaming folder. Fixes #13224.

This commit is contained in:
Henrik Rydgård 2020-12-20 00:41:28 +01:00
parent 89d20e4ab8
commit d771dca3da
2 changed files with 21 additions and 9 deletions

View file

@ -238,20 +238,30 @@ bool PathBrowser::GetListing(std::vector<FileInfo> &fileInfo, const char *filter
}
}
void PathBrowser::NavigateUp() {
// Upwards.
// Check for windows drives.
if (path_.size() == 3 && path_[1] == ':') {
path_ = "/";
} else if (startsWith(path_, "http://") || startsWith(path_, "https://")) {
// You can actually pin "remote disc streaming" (which I didn't even realize until recently).
// This prevents you from getting the path browser into very weird states:
path_ = "/";
// It's ok to just go directly to root without more checking since remote disc streaming
// does not yet support folders.
} else {
size_t slash = path_.rfind('/', path_.size() - 2);
if (slash != std::string::npos)
path_ = path_.substr(0, slash + 1);
}
}
// TODO: Support paths like "../../hello"
void PathBrowser::Navigate(const std::string &path) {
if (path == ".")
return;
if (path == "..") {
// Upwards.
// Check for windows drives.
if (path_.size() == 3 && path_[1] == ':') {
path_ = "/";
} else {
size_t slash = path_.rfind('/', path_.size() - 2);
if (slash != std::string::npos)
path_ = path_.substr(0, slash + 1);
}
NavigateUp();
} else {
if (path.size() > 2 && path[1] == ':' && path_ == "/")
path_ = path;

View file

@ -22,6 +22,8 @@ public:
void SetPath(const std::string &path);
bool IsListingReady();
bool GetListing(std::vector<FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);
void NavigateUp();
void Navigate(const std::string &path);
std::string GetPath() const {