#include "libublsettings.h" char *yon_file_path_proceed_spaces(char *path){ int size; config_str parsed = yon_char_parse(path,&size,"/"); for (int i=0;ipw_uid,user->pw_gid)){}; if (file){ fputs(text,file); fclose(file); return 1; } return 0; } int yon_file_create(char *path, char *name, int rules){ if (path&&name){ char *full_path = yon_char_unite(path,"/",name,NULL); if (access(full_path,F_OK)){ FILE *fl = fopen(full_path,"w"); if (fl){ struct passwd *user = getpwnam(yon_ubl_root_user_get()); if (chown(path,user->pw_uid,user->pw_gid)){}; fclose(fl); return 1; } else { return 0; } } else { return -1; } } else { return 0; } } int yon_file_create_full_path(char *path, mode_t rules){ if (path){ if (access(path,F_OK)){ int size; config_str parsed = yon_char_parse(path,&size,"/"); char *current = ""; for (int i=0;id_type==DT_DIR &&(strcmp(cur_dir->d_name, ".") && strcmp(cur_dir->d_name, ".."))){ yon_char_parsed_add_or_create_if_exists(final,size,cur_dir->d_name); } } closedir(current_dir); return final; } return NULL; } config_str yon_file_ls(char *path, int *size){ (*size)=0; if (!yon_char_is_empty(path)&&!access(path,F_OK)){ config_str final = NULL; DIR *current_dir = opendir(path); struct dirent* cur_dir; while ((cur_dir=readdir(current_dir))){ if ((strcmp(cur_dir->d_name, ".") && strcmp(cur_dir->d_name, ".."))){ yon_char_parsed_add_or_create_if_exists(final,size,cur_dir->d_name); } } closedir(current_dir); return final; } return NULL; } int yon_file_is_directory(const char *path) { struct stat path_stat; stat(path, &path_stat); return S_ISDIR(path_stat.st_mode); } void yon_dir_remove(const char *path){ DIR *d = opendir(path); struct dirent *dir; if (d) { while ((dir = readdir(d)) != NULL) { if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) { continue; } char full_path[1024]; snprintf(full_path, sizeof(full_path), "%s/%s", path, dir->d_name); if (dir->d_type == DT_DIR) { yon_dir_remove(full_path); } else { unlink(full_path); } } closedir(d); rmdir(path); } }