X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=plocate.cpp;h=6b8b3d8dcad564ba335ba957864363cec8ddf4ab;hb=eb4a3c2c5efd9ce0e204e54c78f64d3d96b49091;hp=1c0b3d0463f09ea04a5f9a39156d91a1e089c7fe;hpb=47afb9a05eafe2c911c5f471046b0de7341a30b0;p=plocate diff --git a/plocate.cpp b/plocate.cpp index 1c0b3d0..6b8b3d8 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -66,7 +66,7 @@ ZSTD_DDict *ddict = nullptr; class Corpus { public: - Corpus(int fd, IOUringEngine *engine); + Corpus(int fd, const char *filename_for_errors, IOUringEngine *engine); ~Corpus(); void find_trigram(uint32_t trgm, function cb); void get_compressed_filename_block(uint32_t docid, function cb) const; @@ -84,7 +84,7 @@ public: Header hdr; }; -Corpus::Corpus(int fd, IOUringEngine *engine) +Corpus::Corpus(int fd, const char *filename_for_errors, IOUringEngine *engine) : fd(fd), engine(engine) { if (flush_cache) { @@ -98,11 +98,11 @@ Corpus::Corpus(int fd, IOUringEngine *engine) complete_pread(fd, &hdr, sizeof(hdr), /*offset=*/0); if (memcmp(hdr.magic, "\0plocate", 8) != 0) { - fprintf(stderr, "plocate.db is corrupt or an old version; please rebuild it.\n"); + fprintf(stderr, "%s: database is corrupt or not a plocate database; please rebuild it.\n", filename_for_errors); exit(1); } if (hdr.version != 0 && hdr.version != 1) { - fprintf(stderr, "plocate.db has version %u, expected 0 or 1; please rebuild it.\n", hdr.version); + fprintf(stderr, "%s: has version %u, expected 0 or 1; please rebuild it.\n", filename_for_errors, hdr.version); exit(1); } if (hdr.version == 0) { @@ -489,7 +489,7 @@ uint64_t do_search_file(const vector &needles, const std::string &filena } IOUringEngine engine(/*slop_bytes=*/16); // 16 slop bytes as described in turbopfor.h. - Corpus corpus(fd, &engine); + Corpus corpus(fd, filename.c_str(), &engine); dprintf("Corpus init done after %.1f ms.\n", 1e3 * duration(steady_clock::now() - start).count()); vector trigram_groups;