| 340 | } |
| 341 | |
| 342 | bool FFTBinaryLookup::loadBinaryAndSignature(std::ifstream &file) |
| 343 | { |
| 344 | { |
| 345 | this->m_binary = new unsigned char [this->m_header.binary_size]; |
| 346 | const std::istream& res = file.read((char*)this->m_binary, this->m_header.binary_size); |
| 347 | if (!res.good()) |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | { |
| 352 | if (this->m_signature != NULL) |
| 353 | { |
| 354 | delete[] this->m_signature; |
| 355 | this->m_signature = 0; |
| 356 | } |
| 357 | |
| 358 | this->m_signature = new char [this->m_header.signature_size]; |
| 359 | const std::istream& res = file.read((char*)this->m_signature, this->m_header.signature_size); |
| 360 | |
| 361 | if (!res.good()) |
| 362 | return false; |
| 363 | |
| 364 | this->m_variants.clear(); |
| 365 | |
| 366 | char * current = this->m_signature; |
| 367 | for (size_t i=0 ; i<this->m_header.signature_size ; ++i) |
| 368 | { |
| 369 | Variant v; |
| 370 | v.m_kind = *(VariantKind*) current; |
| 371 | i += sizeof(int); |
| 372 | current += sizeof(int); |
| 373 | |
| 374 | v.m_size = *(size_t*) current; |
| 375 | i += sizeof(size_t); |
| 376 | current += sizeof(size_t); |
| 377 | |
| 378 | v.m_data = new char[v.m_size]; |
| 379 | memcpy(v.m_data, current, v.m_size); |
| 380 | i += v.m_size; |
| 381 | current += v.m_size; |
| 382 | |
| 383 | this->m_variants.push_back(v); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | return true; |
| 388 | } |
| 389 | |
| 390 | bool FFTBinaryLookup::tryLoadCacheFile() |
| 391 | { |