diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-01-04 23:33:00 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-01-04 23:33:00 +0000 |
| commit | 513ac2cefb0ca8ebe6762cc1313ea9be813c646f (patch) | |
| tree | d9310313972c7b66c68b6908fb1c0c434e30274d /src | |
| parent | daf6233204d381de4ec1d3a6c08c06d5973f9b90 (diff) | |
Do read of image folders during the examine step; fixes #987.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/image_content.cc | 28 | ||||
| -rw-r--r-- | src/lib/image_content.h | 2 |
2 files changed, 19 insertions, 11 deletions
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<const Film> 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> 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<const Film> 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<UserProperty>& p) const; + + boost::optional<boost::filesystem::path> _path_to_scan; }; #endif |
