38 static const uint64_t npos = 0xFFFFFFFFFFFFFFFFLL;
41 swarm_header(
const std::string &type,
int flags_ = 0, uint64_t datalen_ = npos)
43 strcpy(magic,
"SWARM");
46 strncpy(this->m_type, type.c_str(),
sizeof(this->m_type));
47 this->m_type[
sizeof(this->m_type)-1] =
'\0';
54 std::string type()
const
56 const char *
c = strstr(m_type,
"//");
57 if(!c) {
return trim(m_type); }
58 return trim(std::string(m_type, c - m_type));
61 bool is_compatible(
const swarm_header &a)
63 bool ffver_ok = memcmp(magic, a.magic, 8) == 0;
64 std::string t = type();
65 bool type_ok = t.empty() || (t == a.type());
66 return ffver_ok && type_ok;
71 struct ALIGN(16) swarm_index_header :
public swarm_header
76 swarm_index_header(
const std::string &type, uint64_t timestamp_ = 0, uint64_t datafile_size_ = 0 , uint64_t datalen_ = npos)
77 : swarm_header(type, 0, datalen_), timestamp(timestamp_),
datafile_size(datafile_size_)