Fixed config creation failure

pull/36/head
parent fc7db60f16
commit a9cad1c28a

@ -2263,22 +2263,33 @@ int yon_file_create(char *path, char *name, int rules){
int yon_file_create_full_path(char *path, int rules){
if (path){
if (access(path,F_OK)){
FILE *fl = fopen(path,"w");
if (fl){
struct passwd *user = getpwnam(yon_ubl_root_user_get());
chown(path,user->pw_uid,user->pw_gid);
chmod(path,rules);
fclose(fl);
return 1;
} else {
return 0;
int size;
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());
int chown_success = chown(temp,user->pw_uid,user->pw_gid);
int chmod_success = chmod(temp,rules);
}
}
if (!yon_char_is_empty(current)) free(current);
current = temp;
}
return 1;
} else {
return -1;
return 0;
}
} else {
return 0;
}
return 0;
}
config_str yon_file_list_dirs (char *path, int *size){

Loading…
Cancel
Save