include stdio include fstream include time include stdlib define DB_CO

 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 <stdio.h>
#include <fstream.h>
#include <time.h>
#include <stdlib.h>
#define DB_CONFIG_FILE_NAME "DB_config.txt"
void InsertDB(char* file_name, int magic_num) {
}
void CreateDB(char* file_name, char* magic_num) {
//adding sequences to DB
InsertDB(file_name, atoi(magic_num));
//creating DB config file
std::ofstream conf_file(DB_CONFIG_FILE_NAME);
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
conf_file << magic_num << '\n';
conf_file << "Creation time: " << asctime(timeinfo);
conf_file.close();
}
void AddDB(char** argv) {
//trying to open DB config file
std::ifstream conf_file(DB_CONFIG_FILE_NAME);
int magic_num;
conf_file >> magic_num;
conf_file.close();
//adding sequences to DB
InsertDB(file_name, magic_num);
}
int main(int argc, char** argv) {
if (argc < 2) {
printf("Too few arguments\n");
printf("\tpossible arguments:\n");
printf("\t\tcreate <file_name> <magic num> - create new DB from <file_name> with <magic_num>\n");
printf("\t\tadd <file_name> - add sequences from <file_name> to exsisting DB\n");
return 0;
}
if (argv[1] == "create")
if (argc > 3) CreateDB(argv[2], argv[3]);
else printf("Not enough arguments\n");
else if (argv[1] == "add") AddDB(argv[2]);
else printf("Unknown command %s\n", argv[1]);
return 0;
}