+ if (_path_to_scan) {
+ job->sub (_("Scanning image files"));
+ vector<boost::filesystem::path> paths;
+ int n = 0;
+ 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());
+ }
+ ++n;
+ if ((n % 1000) == 0) {
+ 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());
+ set_paths (paths);
+ }