X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=util.cpp;h=b427625219964924db9a88a4f9336523abee7ac8;hb=928743085b7f0f88b3e1b0e59e2d7ebec7816bd2;hp=592e4d56b47f842a6bb6493e634992bb9cfe0ec5;hpb=93b0136eb2bd31043526b95dc3e920bc2ab880ee;p=movit diff --git a/util.cpp b/util.cpp index 592e4d5..b427625 100644 --- a/util.cpp +++ b/util.cpp @@ -42,3 +42,18 @@ void hsv2rgb(float h, float s, float v, float *r, float *g, float *b) *g += m; *b += m; } + +std::string read_file(const std::string &filename) +{ + static char buf[131072]; + FILE *fp = fopen(filename.c_str(), "r"); + if (fp == NULL) { + perror(filename.c_str()); + exit(1); + } + + int len = fread(buf, 1, sizeof(buf), fp); + fclose(fp); + + return std::string(buf, len); +}