summaryrefslogtreecommitdiff
path: root/src/inc/write_file.h
diff options
context:
space:
mode:
authorbyte2016 <[email protected]>2018-09-21 14:35:52 +0800
committerbyte2016 <[email protected]>2018-09-21 14:35:52 +0800
commit80ebf4cdb29204fd5026b270994a0446312f6d8f (patch)
treedde90abd2f1eea539ce4299d114176b7a5692ec7 /src/inc/write_file.h
Init
Diffstat (limited to 'src/inc/write_file.h')
-rw-r--r--src/inc/write_file.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/inc/write_file.h b/src/inc/write_file.h
new file mode 100644
index 0000000..1443cb7
--- /dev/null
+++ b/src/inc/write_file.h
@@ -0,0 +1,80 @@
+#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];//only for determinant business
+ char dest_file_name[MAX_PATH_LENGTH];//only for determinant 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(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
+
+
+