-
Notifications
You must be signed in to change notification settings - Fork 0
/
iofile_interface.cpp
51 lines (41 loc) · 989 Bytes
/
iofile_interface.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
#include "iofile_interface.h"
#include <iostream>
#include <fstream>
using namespace std;
IOfile_interface::IOfile_interface(record_ext *buffer)
{
rec=buffer;
record_size=sizeof(*buffer);
cout<<"IOfile_interface buffer size: "<<record_size<<endl;
}
bool IOfile_interface::input_open(const char* in_file_name)
{
in_file.open(in_file_name, std::ios::in | std::ios::binary);
return in_file.good();
}
bool IOfile_interface::output_open(const char* out_file_name)
{
out_file.open(out_file_name, std::ios::trunc | std::ios::binary);
return out_file.good();
}
void IOfile_interface::input_close()
{
in_file.close();
}
void IOfile_interface::output_close()
{
out_file.close();
}
bool IOfile_interface::input_get(int index)
{
in_file.seekg(record_size*index,in_file.beg);
in_file.read((char*)rec, record_size);
}
bool IOfile_interface::input_get()
{
in_file.read((char*)rec, record_size);
}
bool IOfile_interface::output_append()
{
out_file.write((char*)rec, record_size);
}