#include "certificates.h"
#include "gamma_lut.h"
#include "xyz_frame.h"
+#include "compose.hpp"
#include "KM_util.h"
#include "KM_fileio.h"
#include "AS_DCP.h"
#include <libxml++/document.h>
#include <openssl/sha.h>
#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
#include <stdexcept>
#include <sstream>
#include <iostream>
using std::setw;
using std::setfill;
using boost::shared_ptr;
-using boost::lexical_cast;
using namespace dcp;
/** Create a UUID.
if (!image) {
opj_destroy_decompress (decoder);
opj_cio_close (cio);
- boost::throw_exception (DCPReadError ("could not decode JPEG2000 codestream of " + lexical_cast<string> (size) + " bytes."));
+ boost::throw_exception (DCPReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size)));
}
opj_destroy_decompress (decoder);
return fopen (p.c_str(), t.c_str ());
#endif
}
+
+boost::optional<boost::filesystem::path>
+dcp::relative_to_root (boost::filesystem::path root, boost::filesystem::path file)
+{
+ boost::filesystem::path::const_iterator i = root.begin ();
+ boost::filesystem::path::const_iterator j = file.begin ();
+
+ while (i != root.end() && j != file.end() && *i == *j) {
+ ++i;
+ ++j;
+ }
+
+ if (i != root.end ()) {
+ return boost::optional<boost::filesystem::path> ();
+ }
+
+ boost::filesystem::path rel;
+ while (j != file.end ()) {
+ rel /= *j++;
+ }
+
+ return rel;
+}