- shared_ptr<Content> content;
-
- string ext = path.extension().string ();
- transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-
- if (valid_image_file (path)) {
- content.reset (new ImageContent (film, path));
- } else if (SndfileContent::valid_file (path)) {
- content.reset (new SndfileContent (film, path));
- } else if (ext == ".srt") {
- content.reset (new SubRipContent (film, path));
+ vector<shared_ptr<Content>> content;
+
+ if (boost::filesystem::is_directory (path)) {
+
+ LOG_GENERAL ("Look in directory %1", path);
+
+ if (boost::filesystem::is_empty (path)) {
+ return content;
+ }
+
+ /* See if this is a set of images or a set of sound files */
+
+ int image_files = 0;
+ int sound_files = 0;
+ int read = 0;
+ for (boost::filesystem::directory_iterator i(path); i != boost::filesystem::directory_iterator() && read < 10; ++i) {
+
+ LOG_GENERAL ("Checking file %1", i->path());
+
+ if (boost::starts_with (i->path().leaf().string(), ".")) {
+ /* We ignore hidden files */
+ LOG_GENERAL ("Ignored %1 (starts with .)", i->path());
+ continue;
+ }
+
+ if (!boost::filesystem::is_regular_file(i->path())) {
+ /* Ignore things which aren't files (probably directories) */
+ LOG_GENERAL ("Ignored %1 (not a regular file)", i->path());
+ continue;
+ }
+
+ if (valid_image_file(i->path())) {
+ ++image_files;
+ }
+
+ if (valid_sound_file(i->path())) {
+ ++sound_files;
+ }
+
+ ++read;
+ }
+
+ if (image_files > 0 && sound_files == 0) {
+ content.push_back (make_shared<ImageContent>(path));
+ } else if (image_files == 0 && sound_files > 0) {
+ for (auto i: boost::filesystem::directory_iterator(path)) {
+ content.push_back (make_shared<FFmpegContent>(i.path()));
+ }
+ }
+