summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-05-13 23:46:37 +0200
committerCarl Hetherington <cth@carlh.net>2023-05-14 20:45:38 +0200
commit0f3797af7a31fab73d2f963d7690d11853f72865 (patch)
treece15dbb2a6107479c81ada77afd1f6178acf9710 /src
parent550794a2a289c4d738292ab74639e1496f55e07e (diff)
Cleanup: make a couple of methods static.
Diffstat (limited to 'src')
-rw-r--r--src/lib/dcp_content.cc100
-rw-r--r--src/lib/dcp_content.h2
2 files changed, 53 insertions, 49 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index 87e59de50..29974a785 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -75,6 +75,58 @@ int const DCPContentProperty::TEXTS = 606;
int const DCPContentProperty::CPL = 607;
+static
+void
+read_sub_directory(boost::filesystem::path p, vector<boost::filesystem::path>& contents)
+{
+ using namespace boost::filesystem;
+
+ LOG_GENERAL ("DCPContent::read_sub_directory reads %1", p.string());
+ for (auto i: directory_iterator(p)) {
+ if (is_regular_file(i.path())) {
+ LOG_GENERAL ("Inside there's regular file %1", i.path().string());
+ contents.push_back(i.path());
+ } else if (is_directory(i.path()) && i.path().filename() != ".AppleDouble") {
+ LOG_GENERAL ("Inside there's directory %1", i.path().string());
+ read_sub_directory(i.path(), contents);
+ } else {
+ LOG_GENERAL("Ignoring %1 from inside: status is %2", i.path().string(), static_cast<int>(status(i.path()).type()));
+ }
+ }
+}
+
+
+static
+vector<boost::filesystem::path>
+read_directory(boost::filesystem::path p)
+{
+ 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 ();
+ }
+ }
+
+ vector<boost::filesystem::path> contents;
+ read_sub_directory(p, contents);
+ return contents;
+}
+
+
DCPContent::DCPContent (boost::filesystem::path p)
: _encrypted (false)
, _needs_assets (false)
@@ -85,7 +137,7 @@ DCPContent::DCPContent (boost::filesystem::path p)
{
LOG_GENERAL ("Creating DCP content from %1", p.string());
- read_directory (p);
+ set_paths(read_directory(p));
set_default_colour_conversion ();
}
@@ -162,52 +214,6 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
}
}
-void
-DCPContent::read_directory (boost::filesystem::path p)
-{
- 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)
-{
- using namespace boost::filesystem;
-
- LOG_GENERAL ("DCPContent::read_sub_directory reads %1", p.string());
- for (auto i: directory_iterator(p)) {
- if (is_regular_file(i.path())) {
- LOG_GENERAL ("Inside there's regular file %1", i.path().string());
- add_path (i.path());
- } else if (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>(status(i.path()).type()));
- }
- }
-}
-
/** @param film Film, or 0 */
void
DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h
index 96ae09521..eb62ac354 100644
--- a/src/lib/dcp_content.h
+++ b/src/lib/dcp_content.h
@@ -181,8 +181,6 @@ private:
void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override;
- void read_directory (boost::filesystem::path);
- void read_sub_directory (boost::filesystem::path);
std::list<dcpomatic::DCPTimePeriod> reels (std::shared_ptr<const Film> film) const;
bool can_reference (
std::shared_ptr<const Film> film,