-
Notifications
You must be signed in to change notification settings - Fork 28
/
FileTest.cpp
51 lines (45 loc) · 1.19 KB
/
FileTest.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
#include "base.h"
using namespace std;
void FileTest()
{
char filepath[100];
ifstream in_file;
char address[13];
cout << "\nPlease input the path and name that you want to test!" << endl;
cout << "\n\t C:\\temp\\myfile.trace" << endl;
cout << "\n\t myfile.trace" << endl;
cin >> filepath;
in_file.open(filepath,ios::in);
while(in_file.fail())
{
cout << "Open ERROR! Please Check the Path and Name, and Input again!" << endl;
cin >> filepath;
in_file.open(filepath,ios::in);
}
#ifdef OUTPUT
int i_line_proceded = 0;
ofstream out_put;
out_put.open("test.log",ios::out);
#endif // OUTPUT
while(!in_file.eof())
{
in_file.getline(address,13);
#ifdef __GNUC__
bool __attribute__((unused)) is_success = GetHitNum(address); //in case of the warning of "Wunused-but-set-variable"
#endif
#ifndef __GNUC__
bool is_success = GetHitNum(address);
#endif
assert(is_success);
#ifdef OUTPUT
i_line_proceded++;
out_put << i_line_proceded << endl;
cout << address << endl;
#endif // OUTPUT
}
#ifdef OUTPUT
out_put.close();
#endif // OUTPUT
in_file.close();
GetHitRate();
}