summaryrefslogtreecommitdiff
path: root/src/write_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/write_file.c')
-rw-r--r--src/write_file.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/write_file.c b/src/write_file.c
index 3849973..c44cf9e 100644
--- a/src/write_file.c
+++ b/src/write_file.c
@@ -79,16 +79,25 @@ int status_for_persistence::write_file_create_file_name(char *part_path_name,cha
char com[MAX_PATH_LENGTH] = {0};int ret = 0;
void *err_logger=common->error_logger;
-////DETERMINANT : generate tmp_file_name
- ret = snprintf(tmp_file_name,MAX_PATH_LENGTH, "%s/%s/%s.%010lld", tmp_path,part_path_name,file_name, index_version);
+ //DETERMINANT : generate tmp_file_name
+ ret = snprintf(tmp_file_name,MAX_PATH_LENGTH, "%s%s/%s.%010lld", tmp_path,part_path_name,file_name, index_version);
if (ret >= MAX_PATH_LENGTH)
{
MESA_HANDLE_RUNTIME_LOG(err_logger,RLOG_LV_FATAL,"[write_file]","file path too long:%s, should not bigger than %d!",tmp_file_name, MAX_PATH_LENGTH);
return -1;
}
-
-//DETERMINANT : generate dest_path_dir
- sprintf(com, "%s/%s/%s", dest_path,part_path_name,time_str);
+ sprintf(com, "%s/%s", tmp_path,part_path_name);
+ ret = create_path_p(com);
+ if(ret != 0)
+ {
+ MESA_HANDLE_RUNTIME_LOG(err_logger,RLOG_LV_FATAL,"[write_file]","can not create dir, com:%s!", com);
+ return -1;
+ }
+ //DETERMINANT : generate dest_path_dir
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ sprintf(com, "%s/%s/%s", dest_path,part_path_name,time_str);
+ else
+ sprintf(com, "%s/%s", dest_path,part_path_name);
ret = create_path_p(com);
if(ret != 0)
{
@@ -96,8 +105,12 @@ int status_for_persistence::write_file_create_file_name(char *part_path_name,cha
return -1;
}
-//DETERMINANT generate dest_file_name
- ret = snprintf(dest_file_name,MAX_PATH_LENGTH, "%s/%s/%s/%s.%010lld", dest_path,part_path_name,part_time_name,file_name,index_version);
+ //DETERMINANT generate dest_file_name
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ ret = snprintf(dest_file_name,MAX_PATH_LENGTH, "%s/%s/%s/%s.%010lld", dest_path,part_path_name,part_time_name,file_name,index_version);
+ else
+ ret = snprintf(dest_file_name,MAX_PATH_LENGTH, "%s/%s/%s.%010lld", dest_path,part_path_name,file_name,index_version);
+
if (ret >= MAX_PATH_LENGTH)
{
MESA_HANDLE_RUNTIME_LOG(err_logger,RLOG_LV_FATAL,"[write_file]","file path too long:%s, should not bigger than %d!",dest_file_name, MAX_PATH_LENGTH);
@@ -170,26 +183,22 @@ int status_for_persistence::write_file_init(int update_type)
// PZ_TYPE_INDETERMINANT :prefix is null
// PZ_TYPE_INDETERMINANT :part_index_name is full_config_index
// PZ_TYPE_INDETERMINANT :part_time_name s null
- if(common->pz_type == PZ_TYPE_DETERMINANT)
+
+ strncpy(part_time_name,time_str,10);
+ if (update_type == UPDATE_TYPE_FULL)
{
- strncpy(part_time_name,time_str,10);
- if (update_type == UPDATE_TYPE_FULL)
- {
- strncpy(part_path_name,"full",5);
- strncpy(part_index_name,"full_config_index",18);
- }
- else
- {
- strncpy(part_path_name,"inc",4);
- strncpy(part_index_name,"inc_config_index",17);
- }
+ strncpy(part_path_name,"full",5);
+ strncpy(part_index_name,"full_config_index",18);
}
else
{
- strncpy(part_index_name,"full_config_index",18);
+ strncpy(part_path_name,"inc",4);
+ strncpy(part_index_name,"inc_config_index",17);
}
+
//get index file path
- ret = write_file_create_index_name(part_path_name,part_index_name);
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ ret = write_file_create_index_name(part_path_name,part_index_name);
if (ret != 0)
{
MESA_HANDLE_RUNTIME_LOG(common->error_logger,RLOG_LV_FATAL,"[write_file]","create:%s name fail",tmp_index_file_name);
@@ -198,8 +207,8 @@ int status_for_persistence::write_file_init(int update_type)
MESA_HANDLE_RUNTIME_LOG(common->runtime_logger,RLOG_LV_FATAL,"[write_file]","create:%s name suceess",tmp_index_file_name);
//get file path
- if(common->pz_type == PZ_TYPE_DETERMINANT)
- ret = write_file_create_file_name(part_path_name,part_time_name);
+ ret = write_file_create_file_name(part_path_name,part_time_name);
+
if (ret != 0)
{
MESA_HANDLE_RUNTIME_LOG(common->error_logger,RLOG_LV_FATAL,"[write_file]","create:%s fail",tmp_file_name);