-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabulate.cc
52 lines (43 loc) · 1.04 KB
/
tabulate.cc
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
/*
** tabulate.cc
**
** for each file in the results directory
** o read it into a result object
** o for each query in theSurvey
** o record/count the answer in our 'report' structure
*/
#include <stdio.h>
#include <dirent.h>
#include "survey.h"
#include "result.h"
#include "report.h"
void
tabulate(SURVEY &theSurvey, char *resultdir)
{
DIR *dirp;
struct dirent *direntp;
FILE *fpResult;
char fname[256];
RESULT theResult(theSurvey.getname());
dirp = opendir(resultdir);
/*
** skip over the dot and dot-dot directories
*/
readdir(dirp);
readdir(dirp);
/*
** iterate on each file in the directory
*/
while ((direntp = readdir(dirp)) != NULL)
{
sprintf(fname, "%s/%s", resultdir, direntp->d_name);
fpResult = fopen(fname, "r");
theResult.readFromDisk(fpResult);
fclose(fpResult);
cout << "Just read " << fname << "\t Survey is ";
if (theResult.getStatus() == COMPLETED)
cout << "Completed.\n";
else
cout << "Not Completed.\n";
}
}