10 : name(std::move(name_)), exitLoop(false)
12 thread = std::thread([
this]() { run(); });
21 void PreCacheFile::run()
24 if (stat(name.c_str(), &st))
return;
25 if (!S_ISREG(st.st_mode)) {
33 fseek(file.get(), 0, SEEK_END);
34 auto size = ftell(file.get());
35 if (
size < 1024 * 1024) {
38 const size_t BLOCK_SIZE = 4096;
45 if (fseek(file.get(), block * BLOCK_SIZE, SEEK_SET))
break;
46 size_t read = fread(buf, 1, BLOCK_SIZE, file.get());
47 if (read != BLOCK_SIZE) {
PreCacheFile(std::string name)
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.