| 388 | } |
| 389 | |
| 390 | bool FFTBinaryLookup::tryLoadCacheFile() |
| 391 | { |
| 392 | // may create empty file or may wait until file is ready |
| 393 | const std::string & filename = this->m_path + this->m_cache_entry_name; |
| 394 | std::ifstream file (filename.c_str(), std::ios_base::binary); |
| 395 | |
| 396 | if (file.is_open()) |
| 397 | { |
| 398 | file.seekg (0, file.end); |
| 399 | size_t length = file.tellg(); |
| 400 | file.seekg (0, file.beg); |
| 401 | |
| 402 | if (length == 0) |
| 403 | { |
| 404 | // the file is corrupted, so return false |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | bool st; |
| 409 | st = loadHeader(file, length); |
| 410 | |
| 411 | if (! st) |
| 412 | return false; |
| 413 | |
| 414 | st = loadBinaryAndSignature(file); |
| 415 | |
| 416 | if (! st) |
| 417 | return false; |
| 418 | |
| 419 | file.close(); |
| 420 | return true; |
| 421 | } |
| 422 | else |
| 423 | { |
| 424 | return false; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | bool FFTBinaryLookup::found() |
| 429 | { |