MCPcopy Create free account
hub / github.com/FastLED/FastLED / readFileToString

Function readFileToString

tests/fl/codec/decode_file.hpp:71–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71static fl::string readFileToString(const char* path) {
72 fl::FILE* f = fl::fopen(path, "rb");
73 if (!f) {
74 return fl::string();
75 }
76 fl::fseek(f, 0, fl::io::seek_end);
77 long len = fl::ftell(f);
78 fl::fseek(f, 0, fl::io::seek_set);
79 if (len <= 0) {
80 fl::fclose(f);
81 return fl::string();
82 }
83 fl::vector<char> buf(len);
84 size_t read = fl::fread(buf.data(), 1, len, f);
85 fl::fclose(f);
86 return fl::string(buf.data(), read);
87}
88
89// ---------------------------------------------------------------------------
90// Codec validation helpers

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 7

fopenFunction · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
fcloseFunction · 0.85
freadFunction · 0.85
stringClass · 0.50
dataMethod · 0.45

Tested by

no test coverage detected