33 const std::string type_name =
"rds_file";
34 const auto& rdsmap = internal_json::extract_typed_object_from_metadata(metadata.
other, type_name);
36 const std::string version_name =
"version";
37 const std::string& vstring = internal_json::extract_string_from_typed_object(rdsmap, version_name, type_name);
38 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
39 if (version.major != 1) {
40 throw std::runtime_error(
"unsupported version string '" + vstring +
"'");
43 auto fpath = path /
"file.rds";
46 internal_files::check_gzip_signature(fpath);
48 const char* expected =
"X\n";
49 size_t expected_len = 2;
51 auto reader = internal_other::open_reader<byteme::GzipFileReader>(fpath, expected_len);
52 byteme::PerByte<> pb(&reader);
53 bool okay = pb.valid();
55 for (
size_t i = 0; i < expected_len; ++i) {
57 throw std::runtime_error(
"incomplete RDS file signature for '" + fpath.string() +
"'");
59 if (pb.get() != expected[i]) {
60 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