*/
-#include "raw_convert.h"
#include "asset.h"
-#include "util.h"
-#include "exceptions.h"
-#include "dcp_assert.h"
+#include "asset_map.h"
#include "compose.hpp"
+#include "dcp_assert.h"
+#include "exceptions.h"
#include "pkl.h"
+#include "raw_convert.h"
+#include "util.h"
+#include "warnings.h"
+LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
+LIBDCP_ENABLE_WARNINGS
#include <boost/algorithm/string.hpp>
return;
}
- pkl->add_asset (_id, _id, hash(), file_size(_file.get()), pkl_type(pkl->standard()));
+ pkl->add_asset(_id, _id, hash(), file_size(_file.get()), pkl_type(pkl->standard()), _file->filename().string());
}
void
-Asset::write_to_assetmap (xmlpp::Node* node, path root) const
+Asset::add_to_assetmap (AssetMap& asset_map, path root) const
{
DCP_ASSERT (_file);
- write_file_to_assetmap (node, root, _file.get(), _id);
+ add_file_to_assetmap (asset_map, root, _file.get(), _id);
}
void
-Asset::write_file_to_assetmap (xmlpp::Node* node, path root, path file, string id)
+Asset::add_file_to_assetmap (AssetMap& asset_map, path root, path file, string id)
{
auto path = relative_to_root (
canonical(root),
return;
}
- auto asset = node->add_child ("Asset");
- asset->add_child("Id")->add_child_text("urn:uuid:" + id);
- auto chunk_list = asset->add_child ("ChunkList");
- auto chunk = chunk_list->add_child ("Chunk");
-
- 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>(file_size(file)));
+ asset_map.add_asset(id, file, false);
}
bool
-Asset::equals (std::shared_ptr<const Asset> other, EqualityOptions, NoteHandler note) const
+Asset::equals(std::shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
if (_hash != other->_hash) {
- note (NoteType::ERROR, "Asset: hashes differ");
- return false;
+ if (!opt.asset_hashes_can_differ) {
+ note(NoteType::ERROR, "Asset: hashes differ");
+ return false;
+ } else {
+ note(NoteType::NOTE, "Asset: hashes differ");
+ }
}
return true;
Asset::set_file (path file) const
{
_file = absolute (file);
- _hash = {};
+ _hash = optional<string>();
+}
+
+
+void
+Asset::set_file_preserving_hash(path file) const
+{
+ _file = absolute(file);
+}
+
+
+void
+Asset::rename_file(path file)
+{
+ _file = absolute(file);
}
{
_hash = hash;
}
+
+
+void
+Asset::unset_hash()
+{
+ _hash = optional<string>();
+}
+