Build an FM index of the specified file. */
| 499 | |
| 500 | /** Build an FM index of the specified file. */ |
| 501 | static void buildFMIndex(FMIndex& fm, const char* path) |
| 502 | { |
| 503 | if (opt::verbose > 0) |
| 504 | std::cerr << "Reading `" << path << "'...\n"; |
| 505 | std::vector<FMIndex::value_type> s; |
| 506 | readFile(path, s); |
| 507 | |
| 508 | uint64_t MAX_SIZE = numeric_limits<FMIndex::sais_size_type>::max(); |
| 509 | if (s.size() > MAX_SIZE) { |
| 510 | std::cerr << PROGRAM << ": `" << path << "', " |
| 511 | << toSI(s.size()) |
| 512 | << "B, must be smaller than " |
| 513 | << toSI(MAX_SIZE) << "B\n"; |
| 514 | exit(EXIT_FAILURE); |
| 515 | } |
| 516 | |
| 517 | transform(s.begin(), s.end(), s.begin(), ::toupper); |
| 518 | fm.setAlphabet(opt::alphabet); |
| 519 | fm.assign(s.begin(), s.end()); |
| 520 | } |
| 521 | |
| 522 | /** Return the size of the specified file. */ |
| 523 | static streampos fileSize(const string& path) |