33 const auto& rdsmap = internal_json::extract_typed_object_from_metadata(metadata.
other,
"rds_file");
35 const std::string& vstring = internal_json::extract_string_from_typed_object(rdsmap,
"version",
"rds_file");
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 +
"'");
41 auto fpath = path /
"file.rds";
44 internal_files::check_gzip_signature(fpath);
46 const char* expected =
"X\n";
47 size_t expected_len = 2;
49 auto reader = internal_other::open_reader<byteme::GzipFileReader>(fpath, expected_len);
50 byteme::PerByte<> pb(&reader);
51 bool okay = pb.valid();
53 for (
size_t i = 0; i < expected_len; ++i) {
55 throw std::runtime_error(
"incomplete RDS file signature for '" + fpath.string() +
"'");
57 if (pb.get() != expected[i]) {
58 throw std::runtime_error(
"incorrect RDS file signature for '" + fpath.string() +
"'");
void validate(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition rds_file.hpp:32