From 91579608b263772cae2a13e165e3abf781943e9d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 7 Jun 2023 17:37:40 +0200 Subject: [PATCH] Remove duplicate API to find session files (ignore `._` files) Session::possible_states correctly filters files and also directly returns sorted base-names. We can remove the redundant `get_state_files_in_directory` API now. see also 193b35e88576e7736c6774708d4024c0d663d83b --- gtk2_ardour/ardour_ui_session.cc | 4 +--- gtk2_ardour/editor_snapshots.cc | 9 ++------- gtk2_ardour/session_dialog.cc | 18 ++---------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/gtk2_ardour/ardour_ui_session.cc b/gtk2_ardour/ardour_ui_session.cc index 298399574d..41c53c0d1b 100644 --- a/gtk2_ardour/ardour_ui_session.cc +++ b/gtk2_ardour/ardour_ui_session.cc @@ -1109,9 +1109,7 @@ ARDOUR_UI::process_snapshot_session_prompter (Prompter& prompter, bool switch_to } } - vector p; - get_state_files_in_directory (_session->session_directory().root_path(), p); - vector n = get_file_names_no_extension (p); + vector n = Session::possible_states (_session->session_directory().root_path()); if (find (n.begin(), n.end(), snapname) != n.end()) { diff --git a/gtk2_ardour/editor_snapshots.cc b/gtk2_ardour/editor_snapshots.cc index e85fa93791..fc6faf847a 100644 --- a/gtk2_ardour/editor_snapshots.cc +++ b/gtk2_ardour/editor_snapshots.cc @@ -202,17 +202,12 @@ EditorSnapshots::redisplay () return; } - vector state_file_paths; + vector state_file_names = _session->possible_states (); - get_state_files_in_directory (_session->session_directory().root_path(), - state_file_paths); - - if (state_file_paths.empty()) { + if (state_file_names.empty()) { return; } - vector state_file_names (get_file_names_no_extension(state_file_paths)); - _snapshot_model->clear (); for (vector::iterator i = state_file_names.begin(); i != state_file_names.end(); ++i) diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc index b30dc32386..c4596f5779 100644 --- a/gtk2_ardour/session_dialog.cc +++ b/gtk2_ardour/session_dialog.cc @@ -786,14 +786,7 @@ SessionDialog::redisplay_recent_sessions () int session_snapshot_count = 0; for (vector::const_iterator i = session_directories.begin(); i != session_directories.end(); ++i) { - std::vector state_file_paths; - // now get available states for this session - - get_state_files_in_directory (*i, state_file_paths); - - vector states; - vector item; string dirname = *i; /* remove any trailing / */ @@ -813,17 +806,10 @@ SessionDialog::redisplay_recent_sessions () } /* now get available states for this session */ - - states = Session::possible_states (dirname); - - if (states.empty()) { - /* no state file? */ - continue; - } - - std::vector state_file_names(get_file_names_no_extension (state_file_paths)); + vector state_file_names = Session::possible_states (dirname); if (state_file_names.empty()) { + /* no state file? */ continue; }