Fixed file creation

pull/41/head
parent cddff6c596
commit 7e1decdcd1

@ -2537,7 +2537,6 @@ int yon_file_save(char *file_path, char *text){
FILE *file = fopen(file_path,"w"); FILE *file = fopen(file_path,"w");
struct passwd *user = getpwnam(yon_ubl_root_user_get()); struct passwd *user = getpwnam(yon_ubl_root_user_get());
if (chown(file_path,user->pw_uid,user->pw_gid)){}; if (chown(file_path,user->pw_uid,user->pw_gid)){};
chmod(file_path,0644);
if (file){ if (file){
fputs(text,file); fputs(text,file);
fclose(file); fclose(file);
@ -2554,7 +2553,6 @@ int yon_file_create(char *path, char *name, int rules){
if (fl){ if (fl){
struct passwd *user = getpwnam(yon_ubl_root_user_get()); struct passwd *user = getpwnam(yon_ubl_root_user_get());
if (chown(path,user->pw_uid,user->pw_gid)){}; if (chown(path,user->pw_uid,user->pw_gid)){};
chmod(full_path,rules);
fclose(fl); fclose(fl);
return 1; return 1;
} else { } else {
@ -2568,7 +2566,7 @@ 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, mode_t rules){
if (path){ if (path){
if (access(path,F_OK)){ if (access(path,F_OK)){
int size; int size;
@ -2580,13 +2578,16 @@ int yon_file_create_full_path(char *path, int rules){
if (access(temp,F_OK)){ if (access(temp,F_OK)){
if (i!=size-1){ if (i!=size-1){
mkdir(temp,0755); mkdir(temp,0755);
struct passwd *user = getpwnam(yon_ubl_root_user_get());
} else { } else {
FILE *fl = fopen(temp,"w"); FILE *fl = fopen(temp,"w");
fclose(fl); fclose(fl);
} }
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 (i>2){
struct passwd *user = getpwnam(yon_ubl_root_user_get());
int chown_success = chown(temp,user->pw_uid,user->pw_gid);
} }
} }
if (!yon_char_is_empty(current)) free(current); if (!yon_char_is_empty(current)) free(current);

@ -697,7 +697,7 @@ int yon_file_create(char *path, char *name, int rules);
* Создать файл по пути [path] * Создать файл по пути [path]
* С правами доступа [rules] (от 0000 до 0777) * С правами доступа [rules] (от 0000 до 0777)
*/ */
int yon_file_create_full_path(char *path, int rules); int yon_file_create_full_path(char *path, mode_t rules);
/**yon_file_ls (char *path, int *size) /**yon_file_ls (char *path, int *size)
* [EN] * [EN]

Loading…
Cancel
Save