-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadkit.cpp
118 lines (101 loc) · 1.97 KB
/
loadkit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*============================================
# Filename: loadkit.cpp
# Ver 1.0 2014-06-08
#
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 or later of the License.
#
# Description:
=============================================*/
#include"loadkit.h"
void loadkit::close()
{
if(r!=NULL)
fclose(r);
r=NULL;
}
loadkit::~loadkit()
{
if(r!=NULL)
fclose(r);
}
loadkit::loadkit(const char * file)
{
this->r=fopen(file,"rb");
if(r==NULL)
{
cout<<"Fopen error"<<endl;
exit(0);
}
}
i32 loadkit::loadi64(i64 & value)
{
i32 num=fread(&value,sizeof(i64),1,r);
return num;
}
i32 loadkit::loadu64(u64 & value)
{
i32 num=fread(&value,sizeof(u64),1,r);
return num;
}
i32 loadkit::loadi32(i32 & value)
{
i32 num=fread(&value,sizeof(i32),1,r);
return num;
}
i32 loadkit::loadu32(u32 & value)
{
i32 num=fread(&value,sizeof(u32),1,r);
return num;
}
i32 loadkit::loadi16(i16 & value)
{
i32 num=fread(&value,sizeof(i16),1,r);
return num;
}
i32 loadkit::loadu16(u16 & value)
{
i32 num=fread(&value,sizeof(u16),1,r);
return num;
}
i32 loadkit::loadu8(u8 & value)
{
i32 num = fread(&value,sizeof(u8),1,r);
return num;
}
i32 loadkit::loadi64array(i64 * value,i32 len)
{
i32 num=fread(value,sizeof(i64),len,r);
return num;
}
i32 loadkit::loadu64array(u64 * value,i32 len)
{
i32 num=fread(value,sizeof(u64),len,r);
return num;
}
i32 loadkit::loadi32array(i32 * value,i32 len)
{
i32 num=fread(value,sizeof(i32),len,r);
return num;
}
i32 loadkit::loadu32array(u32 * value,i32 len)
{
i32 num=fread(value,sizeof(u32),len,r);
return num;
}
i32 loadkit::loadi16array(i16 * value,i32 len)
{
i32 num=fread(value,sizeof(i16),len,r);
return num;
}
i32 loadkit::loadu16array(u16 * value,i32 len)
{
i32 num=fread(value,sizeof(u16),len,r);
return num;
}
i32 loadkit::loadu8array(u8 * value,i32 len)
{
i32 num = fread(value,sizeof(u8),len,r);
return num;
}