MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / Load

Method Load

src/openboardview/history.cpp:18–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18int FHistory::Load(void) {
19 if (!fname.empty()) {
20 FILE *f;
21#ifdef _WIN32
22 errno_t e;
23 e = fopen_s(&f, fname.c_str(), "r");
24#else
25 f = fopen(fname.c_str(), "r");
26#endif
27
28 count = 0;
29 if (!f) return 0;
30
31 while (count < FHISTORY_COUNT_MAX) {
32 char *r;
33
34 r = fgets(history[count], FHISTORY_FNAME_LEN_MAX, f);
35 if (r) {
36 count++;
37
38 /// strip off the trailing line break
39 while (*r) {
40 if ((*r == '\r') || (*r == '\n')) {
41 *r = '\0';
42 break;
43 }
44 r++;
45 }
46
47 } else {
48 break;
49 }
50 }
51 fclose(f);
52 } else {
53 return -1;
54 }
55
56 return count;
57}
58
59int FHistory::Prepend_save(const std::string &newfile) {
60 if (!fname.empty()) {

Callers 6

mainFunction · 0.45
LoadFileMethod · 0.45
loadFromConfigMethod · 0.45
writeToConfigMethod · 0.45
loadFromConfigMethod · 0.45
writeToConfigMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected