-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPathConfig.cc
More file actions
53 lines (45 loc) · 1.41 KB
/
PathConfig.cc
File metadata and controls
53 lines (45 loc) · 1.41 KB
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
#include "PathConfig.h"
PathConfig *PathConfig::instance = NULL;
PathConfig::PathConfig() {
FILE *fp = fopen(settings, "r");
if (fp) {
char *mem = (char *) malloc(80 * 3);
catalogDir = &mem[0];
dbFileDir = &mem[80];
statisticsFilePath = &mem[160];
char line[80];
fgets(line, 80, fp);
sscanf(line, "%s\n", catalogDir);
fgets(line, 80, fp);
sscanf(line, "%s\n", dbFileDir);
fgets(line, 80, fp);
sscanf(line, "%s\n", statisticsFilePath);
if (!(catalogDir && dbFileDir && statisticsFilePath)) {
cerr << " Test settings file 'test.cat' not in correct format.\n";
free(mem);
exit(1);
}
} else {
cerr << " Test settings files 'test.cat' missing \n";
exit(1);
}
}
char *PathConfig::GetSchemaPath(const char *tableName) {
char *path = new char[100];
sprintf(path, "%s%s.schema", catalogDir, tableName);
return path;
}
char *PathConfig::GetDBFilePath(const char *tableName) {
char *path = new char[100];
sprintf(path, "%s%s.bin", dbFileDir, tableName);
return path;
}
char *PathConfig::GetMetadataFilePath(const char *filePath) {
char *path = new char[100];
// Change this to "%s.bin.metadata"
sprintf(path, "%s.metadata", filePath);
return path;
}
char *PathConfig::GetStatisticsFilePath() {
return this->statisticsFilePath;
}