From 17c46c84f24071cc7f50fb439967cffb3778e4de Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 9 Sep 2012 16:11:02 +0100 Subject: Cope with paths having file:// at the start of them. --- src/asset_map.cc | 8 ++++++++ src/util.cc | 10 ++++++++++ src/util.h | 1 + test/ref/info.log | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/src/asset_map.cc b/src/asset_map.cc index 31809c9b..35f96c45 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -22,6 +22,7 @@ */ #include "asset_map.h" +#include "util.h" using namespace std; using namespace boost; @@ -50,6 +51,13 @@ Chunk::Chunk (xmlpp::Node const * node) : XMLNode (node) { path = string_node ("Path"); + + string const prefix = "file://"; + + if (starts_with (path, prefix)) { + path = path.substr (prefix.length()); + } + volume_index = optional_int64_node ("VolumeIndex"); offset = optional_int64_node ("Offset"); length = optional_int64_node ("Length"); diff --git a/src/util.cc b/src/util.cc index ad6a66fe..fd76e556 100644 --- a/src/util.cc +++ b/src/util.cc @@ -148,6 +148,16 @@ libdcp::content_kind_from_string (string type) assert (false); } +bool +libdcp::starts_with (string big, string little) +{ + if (little.size() > big.size()) { + return false; + } + + return big.substr (0, little.length()) == little; +} + bool libdcp::ends_with (string big, string little) { diff --git a/src/util.h b/src/util.h index af6a08d6..9485c450 100644 --- a/src/util.h +++ b/src/util.h @@ -46,6 +46,7 @@ extern std::string make_digest (std::string filename, sigc::signal1 extern std::string content_kind_to_string (ContentKind kind); extern ContentKind content_kind_from_string (std::string kind); +extern bool starts_with (std::string big, std::string little); extern bool ends_with (std::string big, std::string little); extern opj_image_t* decompress_j2k (uint8_t* data, int64_t size, int reduce); diff --git a/test/ref/info.log b/test/ref/info.log index fdd6537e..2f1c6e93 100644 --- a/test/ref/info.log +++ b/test/ref/info.log @@ -82,6 +82,11 @@ DCP: ../libdcp-test/MACHINE-GUN-PREACH_TLR-1_F_EN-de-fr_CH_51_2K_TIT_20111107 Frames per second: 24 Reel 1 Subtitle: 94 subtitles in English +DCP: ../libdcp-test/DU-VENT-DANS-MES-MOLLETS_TLR_F_FR-XX_FR_51_2K_GA_20120621_ECL_OV + CPL: DU-VENT-DANS-MES-MOLLETS_TLR_F_FR-XX_FR_51_2K_GA_20120621_ECL_OV + Length: 2502 + Frames per second: 24 + Reel 1 DCP: ../libdcp-test/ASTERIX_TLR-01_F_FR-DE_CH_51_2K_FRE_20120730_DGL_OV CPL: Length: 3080 -- cgit v1.2.3