15 : name(
std::move(name_)), exitLoop(false)
17 thread = std::thread([
this]() { run(); });
26void PreCacheFile::run()
36 fseek(file.get(), 0, SEEK_END);
37 auto size = ftell(file.get());
38 if (
size < 1024l * 1024l) {
41 const size_t BLOCK_SIZE = 4096;
47 std::array<char, BLOCK_SIZE> buf;
48 if (fseek(file.get(), narrow_cast<long>(block * BLOCK_SIZE), SEEK_SET))
break;
49 size_t read = fread(buf.data(), 1, BLOCK_SIZE, file.get());
50 if (read != BLOCK_SIZE) {
PreCacheFile(std::string name)
bool isRegularFile(const Stat &st)
FILE_t openFile(zstring_view filename, zstring_view mode)
Call fopen() in a platform-independent manner.
This file implemented 3 utility functions:
size_t size(std::string_view utf8)
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.