34 const std::string type_name =
"bigwig_file";
35 const std::string& vstring = internal_json::extract_version_for_type(metadata.
other, type_name);
36 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
37 if (version.major != 1) {
38 throw std::runtime_error(
"unsupported version string '" + vstring +
"'");
43 auto ipath = path /
"file.bw";
44 std::array<unsigned char, 4> store;
45 internal_files::extract_signature(ipath, store.data(), store.size());
47 std::array<unsigned char, 4> be_magic { 0x26, 0xFC, 0x8F, 0x88 };
48 std::array<unsigned char, 4> le_magic { 0x88, 0x8F, 0xFC, 0x26 };
49 if (store != be_magic && store != le_magic) {
50 throw std::runtime_error(
"incorrect bigWig file signature for '" + ipath.string() +
"'");