- for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
- if (boost::filesystem::is_regular_file (i->path())) {
- _paths.push_back (i->path());
- } else if (boost::filesystem::is_directory (i->path ())) {
- read_directory (i->path());
+ using namespace boost::filesystem;
+
+ bool have_assetmap = false;
+ bool have_metadata = false;
+
+ for (auto i: directory_iterator(p)) {
+ if (i.path().filename() == "ASSETMAP" || i.path().filename() == "ASSETMAP.xml") {
+ have_assetmap = true;
+ } else if (i.path().filename() == "metadata.xml") {
+ have_metadata = true;
+ }
+ }
+
+ if (!have_assetmap) {
+ if (!have_metadata) {
+ throw DCPError ("No ASSETMAP or ASSETMAP.xml file found: is this a DCP?");
+ } else {
+ throw ProjectFolderError ();
+ }
+ }
+
+ read_sub_directory (p);
+}
+
+void
+DCPContent::read_sub_directory (boost::filesystem::path p)
+{
+ LOG_GENERAL ("DCPContent::read_sub_directory reads %1", p.string());
+ for (auto i: boost::filesystem::directory_iterator(p)) {
+ if (boost::filesystem::is_regular_file(i.path())) {
+ LOG_GENERAL ("Inside there's regular file %1", i.path().string());
+ add_path (i.path());
+ } else if (boost::filesystem::is_directory(i.path()) && i.path().filename() != ".AppleDouble") {
+ LOG_GENERAL ("Inside there's directory %1", i.path().string());
+ read_sub_directory (i.path());
+ } else {
+ LOG_GENERAL("Ignoring %1 from inside: status is %2", i.path().string(), static_cast<int>(boost::filesystem::status(i.path()).type()));