From dfa7b94e802b05bba4243381460eef96626102a0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 11 Nov 2023 01:31:58 +0100 Subject: Replace deprecated leaf() with filename(). --- src/lib/content_factory.cc | 2 +- src/lib/create_cli.cc | 2 +- src/lib/film.cc | 2 +- src/lib/image_filename_sorter.cc | 2 +- src/lib/job.cc | 2 +- src/lib/playlist.cc | 2 +- src/lib/types.cc | 2 +- src/lib/uploader.cc | 2 +- src/lib/util.cc | 4 ++-- src/wx/download_certificate_panel.cc | 2 +- src/wx/file_picker_ctrl.cc | 2 +- src/wx/fonts_dialog.cc | 2 +- src/wx/system_font_dialog.cc | 2 +- test/ffmpeg_dcp_test.cc | 2 +- test/test.cc | 4 ++-- test/threed_test.cc | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index e1278c3b4..dfa1ba55e 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -129,7 +129,7 @@ content_factory (boost::filesystem::path path) LOG_GENERAL ("Checking file %1", i->path()); - if (boost::starts_with (i->path().leaf().string(), ".")) { + if (boost::starts_with(i->path().filename().string(), ".")) { /* We ignore hidden files */ LOG_GENERAL ("Ignored %1 (starts with .)", i->path()); continue; diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index 6752be409..1c2f2c635 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -316,7 +316,7 @@ CreateCLI::CreateCLI (int argc, char* argv[]) } if (_name.empty()) { - _name = content[0].path.leaf().string(); + _name = content[0].path.filename().string(); } if (_j2k_bandwidth && (*_j2k_bandwidth < 10000000 || *_j2k_bandwidth > Config::instance()->maximum_j2k_bandwidth())) { diff --git a/src/lib/film.cc b/src/lib/film.cc index b4ad0d0f4..7ba245422 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1303,7 +1303,7 @@ Film::cpls () const for (auto const& item: dcp::filesystem::directory_iterator(dir)) { if ( dcp::filesystem::is_directory(item) && - item.path().leaf() != "j2c" && item.path().leaf() != "video" && item.path().leaf() != "info" && item.path().leaf() != "analysis" + item.path().filename() != "j2c" && item.path().filename() != "video" && item.path().filename() != "info" && item.path().filename() != "analysis" ) { try { diff --git a/src/lib/image_filename_sorter.cc b/src/lib/image_filename_sorter.cc index ab0d298fc..f0370bdcb 100644 --- a/src/lib/image_filename_sorter.cc +++ b/src/lib/image_filename_sorter.cc @@ -54,7 +54,7 @@ string ImageFilenameSorter::extract_numbers (boost::filesystem::path p) { string numbers; - auto const ps = p.leaf().string(); + auto const ps = p.filename().string(); for (size_t i = 0; i < ps.size(); ++i) { if (isdigit (ps[i])) { numbers += ps[i]; diff --git a/src/lib/job.cc b/src/lib/job.cc index 727456523..28bdde7fc 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -111,7 +111,7 @@ Job::run_wrapper () } catch (dcp::FileError& e) { - string m = String::compose (_("An error occurred whilst handling the file %1."), boost::filesystem::path (e.filename()).leaf()); + string m = String::compose(_("An error occurred whilst handling the file %1."), e.filename().filename()); try { auto const s = dcp::filesystem::space(e.filename()); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 7f8292c7f..85957e106 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -684,7 +684,7 @@ Playlist::content_summary (shared_ptr film, DCPTimePeriod period) co } if (score > best_score) { - best_summary = i->path(0).leaf().string(); + best_summary = i->path(0).filename().string(); best_score = score; } } diff --git a/src/lib/types.cc b/src/lib/types.cc index a87c354f3..58382fdc7 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -45,7 +45,7 @@ using dcp::raw_convert; CPLSummary::CPLSummary (boost::filesystem::path p) - : dcp_directory (p.leaf().string()) + : dcp_directory(p.filename().string()) { dcp::DCP dcp (p); diff --git a/src/lib/uploader.cc b/src/lib/uploader.cc index c5448e469..f2a47f50e 100644 --- a/src/lib/uploader.cc +++ b/src/lib/uploader.cc @@ -76,7 +76,7 @@ Uploader::upload_directory (boost::filesystem::path base, boost::filesystem::pat if (is_directory(i.path())) { upload_directory (base, i.path(), transferred, total_size); } else { - _set_status (String::compose(_("copying %1"), i.path().leaf())); + _set_status(String::compose(_("copying %1"), i.path().filename())); upload_file (i.path(), remove_prefix (base, i.path()), transferred, total_size); } } diff --git a/src/lib/util.cc b/src/lib/util.cc index e0b5a294f..71aee88fe 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -673,7 +673,7 @@ short_audio_channel_name (int c) bool valid_image_file (boost::filesystem::path f) { - if (boost::starts_with (f.leaf().string(), "._")) { + if (boost::starts_with(f.filename().string(), "._")) { return false; } @@ -690,7 +690,7 @@ valid_image_file (boost::filesystem::path f) bool valid_sound_file (boost::filesystem::path f) { - if (boost::starts_with (f.leaf().string(), "._")) { + if (boost::starts_with(f.filename().string(), "._")) { return false; } diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index b3de4ca2c..3f1509f60 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -74,7 +74,7 @@ optional DownloadCertificatePanel::load_certificate_from_chain (boost::filesystem::path file, string url) { try { - _certificate = dcp::CertificateChain (dcp::file_to_string(file)).leaf(); + _certificate = dcp::CertificateChain(dcp::file_to_string(file)).leaf(); _url = url; } catch (dcp::MiscError& e) { return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); diff --git a/src/wx/file_picker_ctrl.cc b/src/wx/file_picker_ctrl.cc index bf4877891..4bb6518ef 100644 --- a/src/wx/file_picker_ctrl.cc +++ b/src/wx/file_picker_ctrl.cc @@ -61,7 +61,7 @@ FilePickerCtrl::SetPath (wxString p) _path = p; if (!_path.IsEmpty ()) { - _file->SetLabel (std_to_wx (filesystem::path (wx_to_std (_path)).leaf().string())); + _file->SetLabel(std_to_wx(filesystem::path(wx_to_std(_path)).filename().string())); } else { _file->SetLabel (_("(None)")); } diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index a035a5ffc..f2c9de5cb 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -121,7 +121,7 @@ FontsDialog::setup () _fonts->SetItem(n, 0, id); _fonts->SetItemData(n, i->id().empty()); if (i->file()) { - _fonts->SetItem(n, 1, i->file()->leaf().string()); + _fonts->SetItem(n, 1, i->file()->filename().string()); } ++n; } diff --git a/src/wx/system_font_dialog.cc b/src/wx/system_font_dialog.cc index 84285de12..9814ededd 100644 --- a/src/wx/system_font_dialog.cc +++ b/src/wx/system_font_dialog.cc @@ -62,7 +62,7 @@ SystemFontDialog::SystemFontDialog (wxWindow* parent) int n = 0; for (auto i: _fonts) { - _list->InsertItem (n++, std_to_wx (i.leaf().stem().string ())); + _list->InsertItem(n++, std_to_wx(i.filename().stem().string())); } auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); diff --git a/test/ffmpeg_dcp_test.cc b/test/ffmpeg_dcp_test.cc index c1c322948..c332759c8 100644 --- a/test/ffmpeg_dcp_test.cc +++ b/test/ffmpeg_dcp_test.cc @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_have_dcp_test, * boost::unit_test::depends_on("ffmp p /= film->dcp_name(); auto i = boost::filesystem::directory_iterator (p); - while (i != boost::filesystem::directory_iterator() && !boost::algorithm::starts_with (i->path().leaf().string(), "j2c")) { + while (i != boost::filesystem::directory_iterator() && !boost::algorithm::starts_with(i->path().filename().string(), "j2c")) { ++i; } diff --git a/test/test.cc b/test/test.cc index 9b08dfb4e..2bd31292a 100644 --- a/test/test.cc +++ b/test/test.cc @@ -843,7 +843,7 @@ dcp_file (shared_ptr film, string prefix) vector matches; std::copy_if(recursive_directory_iterator(film->dir(film->dcp_name())), recursive_directory_iterator(), std::back_inserter(matches), [&prefix](directory_entry const& entry) { - return boost::algorithm::starts_with(entry.path().leaf().string(), prefix); + return boost::algorithm::starts_with(entry.path().filename().string(), prefix); }); BOOST_REQUIRE_MESSAGE(matches.size() == 1, "Found " << matches.size() << " files with prefix " << prefix); @@ -854,7 +854,7 @@ boost::filesystem::path subtitle_file (shared_ptr film) { for (auto i: boost::filesystem::recursive_directory_iterator(film->directory().get() / film->dcp_name(false))) { - if (boost::algorithm::starts_with(i.path().leaf().string(), "sub_")) { + if (boost::algorithm::starts_with(i.path().filename().string(), "sub_")) { return i.path(); } } diff --git a/test/threed_test.cc b/test/threed_test.cc index a53b4d10e..698fcba0b 100644 --- a/test/threed_test.cc +++ b/test/threed_test.cc @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(threed_passthrough_test, * boost::unit_test::depends_on("th std::vector matches; std::copy_if(recursive_directory_iterator(*input_dcp), recursive_directory_iterator(), std::back_inserter(matches), [](directory_entry const& entry) { - return boost::algorithm::starts_with(entry.path().leaf().string(), "j2c"); + return boost::algorithm::starts_with(entry.path().filename().string(), "j2c"); }); BOOST_REQUIRE_EQUAL(matches.size(), 1U); -- cgit v1.2.3