line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
namespace panda { namespace time { |
5
|
|
|
|
|
|
|
|
6
|
1303
|
|
|
|
|
|
string readfile (const string_view& path) { |
7
|
1303
|
|
|
|
|
|
char spath[path.length()+1]; // need to make path null-terminated |
8
|
1303
|
|
|
|
|
|
std::memcpy(spath, path.data(), path.length()); |
9
|
1303
|
|
|
|
|
|
spath[path.length()] = 0; |
10
|
|
|
|
|
|
|
|
11
|
1303
|
50
|
|
|
|
|
FILE* fh = fopen(spath, "rb"); |
12
|
1303
|
100
|
|
|
|
|
if (fh == NULL) return string(); |
13
|
|
|
|
|
|
|
|
14
|
1252
|
50
|
|
|
|
|
if (fseek(fh, 0, SEEK_END) != 0) { |
15
|
0
|
0
|
|
|
|
|
fclose(fh); |
16
|
0
|
|
|
|
|
|
return string(); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
1252
|
50
|
|
|
|
|
auto size = ftell(fh); |
20
|
1252
|
50
|
|
|
|
|
if (size < 0) { |
21
|
0
|
0
|
|
|
|
|
fclose(fh); |
22
|
0
|
|
|
|
|
|
return string(); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1252
|
50
|
|
|
|
|
rewind(fh); |
26
|
2555
|
50
|
|
|
|
|
string ret(size); |
27
|
1252
|
50
|
|
|
|
|
size_t readsize = fread(ret.buf(), sizeof(char), size, fh); |
|
|
50
|
|
|
|
|
|
28
|
1252
|
50
|
|
|
|
|
if (readsize != (size_t)size) return string(); |
29
|
|
|
|
|
|
|
|
30
|
1252
|
50
|
|
|
|
|
fclose(fh); |
31
|
1252
|
|
|
|
|
|
ret.length(readsize); |
32
|
1252
|
50
|
|
|
|
|
return ret; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
}} |