Fixed config creation failure

pull/36/head
parent fc7db60f16
commit a9cad1c28a

@ -2263,23 +2263,34 @@ int yon_file_create(char *path, char *name, int rules){
int yon_file_create_full_path(char *path, int rules){ int yon_file_create_full_path(char *path, int rules){
if (path){ if (path){
if (access(path,F_OK)){ if (access(path,F_OK)){
FILE *fl = fopen(path,"w"); int size;
if (fl){ config_str parsed = yon_char_parse(path,&size,"/");
char *current = "";
for (int i=0;i<size;i++){
char *temp = yon_char_unite(current,strcmp(current,"/")?"/":"",parsed[i],NULL);
if (!yon_char_is_empty(temp)){
if (access(temp,F_OK)){
if (i!=size-1){
mkdir(temp,0555);
} else {
FILE *fl = fopen(temp,"w");
}
struct passwd *user = getpwnam(yon_ubl_root_user_get()); struct passwd *user = getpwnam(yon_ubl_root_user_get());
chown(path,user->pw_uid,user->pw_gid); int chown_success = chown(temp,user->pw_uid,user->pw_gid);
chmod(path,rules); int chmod_success = chmod(temp,rules);
fclose(fl); }
}
if (!yon_char_is_empty(current)) free(current);
current = temp;
}
return 1; return 1;
} else { } else {
return 0; return 0;
} }
} else {
return -1;
} }
} else {
return 0; return 0;
} }
}
config_str yon_file_list_dirs (char *path, int *size){ config_str yon_file_list_dirs (char *path, int *size){
(*size)=0; (*size)=0;

Loading…
Cancel
Save