MCPcopy Create free account
hub / github.com/defold/defold / ReadFile

Function ReadFile

engine/dlib/src/test/test_zip.cpp:25–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include <dlib/zip.h>
24
25static bool ReadFile(const char* relative_path, std::string* out)
26{
27 char path[1024];
28 dmTestUtil::MakeHostPath(path, sizeof(path), relative_path);
29
30 FILE* file = fopen(path, "rb");
31 if (file == 0)
32 return false;
33
34 fseek(file, 0, SEEK_END);
35 long file_size = ftell(file);
36 fseek(file, 0, SEEK_SET);
37
38 out->resize(file_size > 0 ? (size_t)file_size : 0);
39 size_t read = 0;
40 if (file_size > 0)
41 read = fread(&(*out)[0], 1, out->size(), file);
42
43 fclose(file);
44 return read == out->size();
45}
46
47static const char* ExpectedNames[] = {
48 "dir/",

Callers 1

SetUpMethod · 0.70

Calls 3

MakeHostPathFunction · 0.85
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected