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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#ifndef WRITE_FILE_H
#define WRITE_FILE_H
#include "common_module.h"
struct status_for_persistence
{
common_module_t * common;
char file_name[MAX_PATH_LENGTH];
char file_path[MAX_PATH_LENGTH];
long long index_version; //maat_version
int total_line_num;
char time_str[MAX_TIME_STR_LENGTH]; //time
char tmp_path[MAX_PATH_LENGTH];//from profile
char dest_path[MAX_PATH_LENGTH];//from profile
char tmp_index_file_name[MAX_PATH_LENGTH];//rename tmp_index_file_name dest_index_file_name
char dest_index_file_name[MAX_PATH_LENGTH];
char tmp_file_name[MAX_PATH_LENGTH];
char dest_file_name[MAX_PATH_LENGTH];
char dest_sample_file_name[MAX_PATH_LENGTH];//only for indeterminant business
FILE *index_fp;
FILE *file_fp;
int is_processed;//solve the problem of multiple call of notify_table_update_end
public:
status_for_persistence(common_module_t * _common
,const char *_file_name
,char *_tmp_path
,char *_dest_path)
{
memset(file_name,0,MAX_PATH_LENGTH);
memset(tmp_path,0,MAX_PATH_LENGTH);
memset(dest_path,0,MAX_PATH_LENGTH);
common = _common;
snprintf(file_name,MAX_PATH_LENGTH,"%s",_file_name);
snprintf(tmp_path,MAX_PATH_LENGTH,"%s",_tmp_path);
snprintf(dest_path,MAX_PATH_LENGTH,"%s",_dest_path);
memset(file_path,0,MAX_PATH_LENGTH);
memset(tmp_index_file_name,0,MAX_PATH_LENGTH);
memset(dest_index_file_name,0,MAX_PATH_LENGTH);
memset(tmp_file_name,0,MAX_PATH_LENGTH);
memset(dest_file_name,0,MAX_PATH_LENGTH);
memset(dest_sample_file_name,0,MAX_PATH_LENGTH);
memset(time_str,0,MAX_TIME_STR_LENGTH);
index_version = 0;
total_line_num = 0;
index_fp = NULL;
file_fp = NULL;
is_processed = 0;
}
//generate dest_path and file name
int write_file_init(int update_type);
int write_file_create_index_name(char *part_path_name,char *part_index_name);
int write_file_create_file_name(char *part_path_name,char *part_time_name);
};
int open_file(FILE ** fp,char *file_path,int flag,void *logger);
int append_to_write_file(FILE *fp, char *msg, void *logger);
int write_file_add_num(FILE *fp,int total_line_num);
int close_file(FILE **fp);
int rename_file (char *src, char *dest,void *logger);
#endif
|