summaryrefslogtreecommitdiff
path: root/src/lib/config.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-02-19 14:32:16 +0000
committerCarl Hetherington <cth@carlh.net>2019-02-19 14:32:16 +0000
commit86bbc0981a60ad9ba7b7bdbf28a34f197f83f6cb (patch)
treef59beeef8d2201de265e916292b025860f3032e3 /src/lib/config.cc
parent8c397a895b1204473ebd8df5108563b1dd0a4e1c (diff)
Don't display non-existant items in the history.
Diffstat (limited to 'src/lib/config.cc')
-rw-r--r--src/lib/config.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index bf4b49552..b742756b7 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -1172,12 +1172,26 @@ Config::add_to_history (boost::filesystem::path p)
add_to_history_internal (_history, p);
}
+/** Remove non-existant items from the history */
+void
+Config::clean_history ()
+{
+ clean_history_internal (_history);
+}
+
void
Config::add_to_player_history (boost::filesystem::path p)
{
add_to_history_internal (_player_history, p);
}
+/** Remove non-existant items from the player history */
+void
+Config::clean_player_history ()
+{
+ clean_history_internal (_player_history);
+}
+
void
Config::add_to_history_internal (vector<boost::filesystem::path>& h, boost::filesystem::path p)
{
@@ -1192,6 +1206,18 @@ Config::add_to_history_internal (vector<boost::filesystem::path>& h, boost::file
changed (HISTORY);
}
+void
+Config::clean_history_internal (vector<boost::filesystem::path>& h)
+{
+ vector<boost::filesystem::path> old = h;
+ h.clear ();
+ BOOST_FOREACH (boost::filesystem::path i, old) {
+ if (boost::filesystem::is_directory(i)) {
+ h.push_back (i);
+ }
+ }
+}
+
bool
Config::have_existing (string file)
{