MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / textFileRead

Function textFileRead

engine/src/textfile.cpp:16–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <string>
15
16char* textFileRead(const char *fn)
17{
18 FILE *file;
19 char *content = NULL;
20
21 int count = 0;
22
23 if (fn != NULL)
24 {
25 const std::string resolvedPath = resolveResourcePath(fn);
26 file = fopen(resolvedPath.c_str(), "rt");
27
28 if (file != NULL)
29 {
30 fseek(file, 0, SEEK_END);
31 count = ftell(file);
32 rewind(file);
33
34 if (count > 0)
35 {
36 content = (char *)malloc(sizeof(char) * (count + 1));
37 count = static_cast<int>(fread(content, sizeof(char), count, file));
38 content[count] = '\0';
39 }
40 fclose(file);
41 }
42 }
43 return content;
44}
45
46int textFileWrite(const char *fn, const char *s)
47{

Callers 1

GL_loadShaderFunction · 0.85

Calls 1

resolveResourcePathFunction · 0.85

Tested by

no test coverage detected