From 513ac2cefb0ca8ebe6762cc1313ea9be813c646f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 4 Jan 2018 23:33:00 +0000 Subject: Do read of image folders during the examine step; fixes #987. --- src/lib/image_content.cc | 28 +++++++++++++++++----------- src/lib/image_content.h | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src/lib') diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index b27483978..191359ff3 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -47,17 +47,7 @@ ImageContent::ImageContent (shared_ptr film, boost::filesystem::path if (boost::filesystem::is_regular_file (p) && valid_image_file (p)) { _paths.push_back (p); } else { - for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) { - if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) { - _paths.push_back (i->path ()); - } - } - - if (_paths.empty()) { - throw FileError (_("No valid image files were found in the folder."), p); - } - - sort (_paths.begin(), _paths.end(), ImageFilenameSorter ()); + _path_to_scan = p; } set_default_colour_conversion (); @@ -113,6 +103,22 @@ ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const void ImageContent::examine (shared_ptr job) { + if (_path_to_scan) { + job->sub (_("Scanning image files")); + for (boost::filesystem::directory_iterator i(*_path_to_scan); i != boost::filesystem::directory_iterator(); ++i) { + if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) { + _paths.push_back (i->path ()); + } + job->set_progress_unknown (); + } + + if (_paths.empty()) { + throw FileError (_("No valid image files were found in the folder."), *_path_to_scan); + } + + sort (_paths.begin(), _paths.end(), ImageFilenameSorter ()); + } + Content::examine (job); shared_ptr film = _film.lock (); diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 660d2ef9f..eeaf1e2b0 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -47,6 +47,8 @@ public: private: void add_properties (std::list& p) const; + + boost::optional _path_to_scan; }; #endif -- cgit v1.2.3