Instead of
static bool file_exists(const std::string &p) { struct stat st{}; return ::stat(p.c_str(), &st) == 0; }
std::filesystem::exists(path);
Instead of
Use the filesystem API, -- https://en.cppreference.com/w/cpp/filesystem.html