UI: Resolve symlinks when adding things to recent.
See #11131. This also normalizes paths, captialization, etc. as necessary.
This commit is contained in:
parent
1fdb1f785a
commit
048afb6d24
7 changed files with 52 additions and 38 deletions
|
@ -1209,30 +1209,34 @@ void Config::AddRecent(const std::string &file) {
|
|||
if (iMaxRecent <= 0)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string filename = ReplaceAll(file, "\\", "/");
|
||||
#else
|
||||
std::string filename = file;
|
||||
#endif
|
||||
|
||||
const std::string filename = File::ResolvePath(file);
|
||||
for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) {
|
||||
#ifdef _WIN32
|
||||
if (!strcmpIgnore((*str).c_str(), filename.c_str(), "\\", "/")) {
|
||||
#else
|
||||
if (!strcmp((*str).c_str(), filename.c_str())) {
|
||||
#endif
|
||||
const std::string recent = File::ResolvePath(*str);
|
||||
if (filename == recent) {
|
||||
recentIsos.erase(str);
|
||||
recentIsos.insert(recentIsos.begin(), filename);
|
||||
if ((int)recentIsos.size() > iMaxRecent)
|
||||
recentIsos.resize(iMaxRecent);
|
||||
return;
|
||||
// We'll add it back below.
|
||||
}
|
||||
}
|
||||
|
||||
recentIsos.insert(recentIsos.begin(), filename);
|
||||
if ((int)recentIsos.size() > iMaxRecent)
|
||||
recentIsos.resize(iMaxRecent);
|
||||
}
|
||||
|
||||
void Config::RemoveRecent(const std::string &file) {
|
||||
// Don't bother with this if the user disabled recents (it's -1).
|
||||
if (iMaxRecent <= 0)
|
||||
return;
|
||||
|
||||
const std::string filename = File::ResolvePath(file);
|
||||
for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) {
|
||||
const std::string recent = File::ResolvePath(*str);
|
||||
if (filename == recent) {
|
||||
recentIsos.erase(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Config::CleanRecent() {
|
||||
std::vector<std::string> cleanedRecent;
|
||||
for (size_t i = 0; i < recentIsos.size(); i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue