} else if (boost::dynamic_pointer_cast<dcp::CPL> (*i)) {
std::cout << "CPL\n";
}
- std::cout << "\t" << (*i)->file().leaf().string() << "\n";
+ std::cout << "\t" << (*i)->file()->leaf().string() << "\n";
}
/* Take the first CPL */
void
Asset::write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const
{
- DCP_ASSERT (!_file.empty ());
+ DCP_ASSERT (_file);
optional<boost::filesystem::path> path = relative_to_root (
boost::filesystem::canonical (root),
- boost::filesystem::canonical (_file)
+ boost::filesystem::canonical (_file.get())
);
if (!path) {
asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
asset->add_child("AnnotationText")->add_child_text (_id);
asset->add_child("Hash")->add_child_text (hash ());
- asset->add_child("Size")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file)));
+ asset->add_child("Size")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file.get())));
asset->add_child("Type")->add_child_text (pkl_type (standard));
}
void
Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
{
- DCP_ASSERT (!_file.empty ());
+ DCP_ASSERT (_file);
optional<boost::filesystem::path> path = relative_to_root (
boost::filesystem::canonical (root),
- boost::filesystem::canonical (_file)
+ boost::filesystem::canonical (_file.get())
);
if (!path) {
chunk->add_child("Path")->add_child_text (path.get().generic_string());
chunk->add_child("VolumeIndex")->add_child_text ("1");
chunk->add_child("Offset")->add_child_text ("0");
- chunk->add_child("Length")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file)));
+ chunk->add_child("Length")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file.get())));
}
string
Asset::hash (function<void (float)> progress) const
{
- DCP_ASSERT (!_file.empty ());
+ DCP_ASSERT (_file);
if (!_hash) {
- _hash = make_digest (_file, progress);
+ _hash = make_digest (_file.get(), progress);
}
return _hash.get();
*/
void write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const;
- /** @return the most recent disk file used to read or write this asset; may be empty */
- boost::filesystem::path file () const {
+ /** @return the most recent disk file used to read or write this asset, if there is one */
+ boost::optional<boost::filesystem::path> file () const {
return _file;
}
protected:
- /** The most recent disk file used to read or write this asset; may be empty */
- mutable boost::filesystem::path _file;
+ /** The most recent disk file used to read or write this asset */
+ mutable boost::optional<boost::filesystem::path> _file;
private:
friend struct ::asset_test;
}
BOOST_FOREACH (shared_ptr<InteropLoadFontNode> j, _load_font_nodes) {
- if (j->uri == font->file().leaf().string ()) {
- _fonts.push_back (Font (j->id, i->id(), font->file ()));
+ if (font->file() && j->uri == font->file()->leaf().string ()) {
+ _fonts.push_back (Font (j->id, i->id(), font->file().get()));
}
}
}
}
ASDCP::JP2K::MXFReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (_file.string().c_str());
+ DCP_ASSERT (_file);
+ Kumu::Result_t r = reader_A.OpenRead (_file->string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", _file.string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", _file->string(), r));
}
ASDCP::JP2K::MXFReader reader_B;
- r = reader_B.OpenRead (other->file().string().c_str());
+ DCP_ASSERT (other->file ());
+ r = reader_B.OpenRead (other->file()->string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", other->file().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", other->file()->string(), r));
}
ASDCP::JP2K::PictureDescriptor desc_A;
#include "mono_picture_asset.h"
#include "mono_picture_frame.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include <asdcp/AS_DCP.h>
using namespace dcp;
: AssetReader (asset)
{
_reader = new ASDCP::JP2K::MXFReader ();
- Kumu::Result_t const r = _reader->OpenRead (asset->file().string().c_str());
+ DCP_ASSERT (asset->file ());
+ Kumu::Result_t const r = _reader->OpenRead (asset->file()->string().c_str());
if (ASDCP_FAILURE (r)) {
delete _reader;
- boost::throw_exception (FileError ("could not open MXF file for reading", asset->file(), r));
+ boost::throw_exception (FileError ("could not open MXF file for reading", asset->file().get(), r));
}
}
asset->fill_writer_info (&state->writer_info, asset->id(), standard);
Kumu::Result_t r = state->mxf_writer.OpenWrite (
- asset->file().string().c_str(),
+ asset->file()->string().c_str(),
state->writer_info,
state->picture_descriptor,
16384,
);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for writing", asset->file().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for writing", asset->file()->string(), r));
}
writer->_started = true;
, _hash (asset->hash ())
{
/* default _annotation_text to the leaf name of our file */
- _annotation_text = asset->file().leaf().string ();
+ if (asset->file ()) {
+ _annotation_text = asset->file()->leaf().string ();
+ }
}
ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
shared_ptr<ASDCP::TimedText::MXFReader> reader (new ASDCP::TimedText::MXFReader ());
- Kumu::Result_t r = reader->OpenRead (_file.string().c_str ());
+ Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
if (!ASDCP_FAILURE (r)) {
/* MXF-wrapped */
ASDCP::WriterInfo info;
{
MXF::set_key (key);
- if (!_key_id || _file.empty()) {
+ if (!_key_id || !_file) {
/* Either we don't have any data to read, or it wasn't
encrypted, so we don't need to do anything else.
*/
/* Our data was encrypted; now we can decrypt it */
shared_ptr<ASDCP::TimedText::MXFReader> reader (new ASDCP::TimedText::MXFReader ());
- Kumu::Result_t r = reader->OpenRead (_file.string().c_str ());
+ Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
if (ASDCP_FAILURE (r)) {
boost::throw_exception (
DCPReadError (
- String::compose ("Could not read encrypted subtitle MXF (%1)", _file, static_cast<int> (r))
+ String::compose ("Could not read encrypted subtitle MXF (%1)", static_cast<int> (r))
)
);
}
SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
ASDCP::PCM::MXFReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
+ DCP_ASSERT (file ());
+ Kumu::Result_t r = reader_A.OpenRead (file()->string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file()->string(), r));
}
ASDCP::PCM::MXFReader reader_B;
- r = reader_B.OpenRead (other->file().string().c_str());
+ r = reader_B.OpenRead (other->file()->string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", other->file()->string(), r));
}
ASDCP::PCM::AudioDescriptor desc_A;
#include "sound_asset.h"
#include "sound_frame.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include <asdcp/AS_DCP.h>
using boost::shared_ptr;
: AssetReader (asset)
{
_reader = new ASDCP::PCM::MXFReader ();
- Kumu::Result_t const r = _reader->OpenRead (asset->file().string().c_str());
+ DCP_ASSERT (asset->file ());
+ Kumu::Result_t const r = _reader->OpenRead (asset->file()->string().c_str());
if (ASDCP_FAILURE (r)) {
delete _reader;
- boost::throw_exception (FileError ("could not open MXF file for reading", asset->file(), r));
+ boost::throw_exception (FileError ("could not open MXF file for reading", asset->file().get(), r));
}
}
StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
ASDCP::JP2K::MXFSReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
+ DCP_ASSERT (file ());
+ Kumu::Result_t r = reader_A.OpenRead (file()->string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file()->string(), r));
}
ASDCP::JP2K::MXFSReader reader_B;
- r = reader_B.OpenRead (other->file().string().c_str());
+ DCP_ASSERT (other->file ());
+ r = reader_B.OpenRead (other->file()->string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", other->file()->string(), r));
}
ASDCP::JP2K::PictureDescriptor desc_A;
#include "stereo_picture_asset.h"
#include "stereo_picture_frame.h"
#include "exceptions.h"
+#include "dcp_assert.h"
#include <asdcp/AS_DCP.h>
using namespace dcp;
: AssetReader (asset)
{
_reader = new ASDCP::JP2K::MXFSReader ();
- Kumu::Result_t const r = _reader->OpenRead (asset->file().string().c_str());
+ DCP_ASSERT (asset->file ());
+ Kumu::Result_t const r = _reader->OpenRead (asset->file()->string().c_str());
if (ASDCP_FAILURE (r)) {
delete _reader;
- boost::throw_exception (FileError ("could not open MXF file for reading", asset->file(), r));
+ boost::throw_exception (FileError ("could not open MXF file for reading", asset->file().get(), r));
}
}
for (list<shared_ptr<Reel> >::iterator j = reels.begin(); j != reels.end(); ++j) {
if ((*j)->main_subtitle()) {
- (*j)->main_subtitle()->asset()->write ((*j)->main_subtitle()->asset()->file ());
+ (*j)->main_subtitle()->asset()->write ((*j)->main_subtitle()->asset()->file().get());
}
}
}