+#include <cstring>
#include <stdexcept>
#include <msp/io/zlibcompressed.h>
#include "collection.h"
namespace Msp {
namespace DataFile {
+const char RawData::signature[4] = { 'M', 'D', 'R', 1 };
+
RawData::~RawData()
{
delete owned_data;
delete in;
}
+bool RawData::detect_signature(const std::string &sig)
+{
+ return !sig.compare(0, string::npos, signature, sizeof(signature));
+}
+
void RawData::open_file(Collection &coll, const string &fn)
{
if(in)
unsigned len = i.read(header, sizeof(header));
if(len!=sizeof(header))
throw data_error(fn, 0, "Missing header");
- if(header[0]!='M' || header[1]!='D' || header[2]!='R' || header[3]!=1)
+ if(memcmp(header, signature, sizeof(signature)))
throw data_error(fn, 0, "Bad header");
size = 0;
char *data = nullptr;
char *owned_data = nullptr;
+ static const char signature[4];
+
public:
~RawData();
+ static bool detect_signature(const std::string &);
+
void open_file(Collection &, const std::string &);
void open_io(IO::Base &, const std::string &);
void load();