mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Validate list of filenames
This commit is contained in:
33
Settings.cpp
33
Settings.cpp
@@ -455,6 +455,39 @@ void Settings::Load()
|
||||
|
||||
}
|
||||
|
||||
void Settings::History::push(const string &filename)
|
||||
{
|
||||
if (filename.empty()) {
|
||||
front_is_valid = false;
|
||||
return;
|
||||
}
|
||||
filenames.remove(filename);
|
||||
filenames.push_front(filename);
|
||||
if (filenames.size() > MAX_RECENT_HISTORY)
|
||||
filenames.pop_back();
|
||||
front_is_valid = true;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Settings::History::remove(const std::string &filename)
|
||||
{
|
||||
if (filename.empty())
|
||||
return;
|
||||
if (filenames.front() == filename)
|
||||
front_is_valid = false;
|
||||
filenames.remove(filename);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Settings::History::validate()
|
||||
{
|
||||
for (auto fit = filenames.begin(); fit != filenames.end();) {
|
||||
if ( SystemToolkit::file_exists( *fit ))
|
||||
++fit;
|
||||
else
|
||||
fit = filenames.erase(fit);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::Lock()
|
||||
{
|
||||
|
||||
23
Settings.h
23
Settings.h
@@ -93,26 +93,9 @@ struct History
|
||||
save_on_exit = false;
|
||||
changed = false;
|
||||
}
|
||||
void push(const std::string &filename) {
|
||||
if (filename.empty()) {
|
||||
front_is_valid = false;
|
||||
return;
|
||||
}
|
||||
filenames.remove(filename);
|
||||
filenames.push_front(filename);
|
||||
if (filenames.size() > MAX_RECENT_HISTORY)
|
||||
filenames.pop_back();
|
||||
front_is_valid = true;
|
||||
changed = true;
|
||||
}
|
||||
void remove(const std::string &filename) {
|
||||
if (filename.empty())
|
||||
return;
|
||||
if (filenames.front() == filename)
|
||||
front_is_valid = false;
|
||||
filenames.remove(filename);
|
||||
changed = true;
|
||||
}
|
||||
void push(const std::string &filename);
|
||||
void remove(const std::string &filename);
|
||||
void validate();
|
||||
};
|
||||
|
||||
struct TransitionConfig
|
||||
|
||||
Reference in New Issue
Block a user