18 : name(
std::move(name_))
20 thread = std::thread([
this]() { run(); });
29void PreCacheFile::run()
const
39 fseek(file.get(), 0, SEEK_END);
40 auto size = ftell(file.get());
41 if (size < 1024L * 1024L) {
44 const size_t BLOCK_SIZE = 4096;
50 std::array<char, BLOCK_SIZE> buf;
51 if (fseek(file.get(), narrow_cast<long>(block * BLOCK_SIZE), SEEK_SET))
break;
52 if (
size_t read = fread(buf.data(), 1, BLOCK_SIZE, file.get());
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:
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.