Added new file functions

pull/23/head
parent 82b564d080
commit abb3f087c9

@ -279,7 +279,10 @@ dictionary *yon_dictionary_get(dictionary **dict, char *key)
dictionary *yon_dictionary_rip(dictionary *dict)
{
if (!dict->next&&!dict->prev) return NULL;
if (!dict->next&&!dict->prev) {
free(dict);
return NULL;
}
else if (!dict->next)
{
dictionary *prev = dict->prev;
@ -2003,6 +2006,47 @@ int yon_file_create_full_path(char *path, int rules){
}
}
config_str yon_file_list_dirs (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 (cur_dir->d_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);
}
// terminal-using functions
int yon_launch_app_with_arguments(char *name, char *args)

@ -300,6 +300,8 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo
#define yon_char_remove_last_symbol(target,symbol) {if (target[strlen(target)-1]==symbol) target[strlen(target)-1]='\0';}
char *yon_char_conenct_if_true();
int yon_char_find_last(char *source, char find);
/**[EN]
@ -594,6 +596,18 @@ int yon_file_create(char *path, char *name, int rules);
*/
int yon_file_create_full_path(char *path, int rules);
/**yon_file_ls (char *path, int *size)
* [EN]
*
* [RU]
* Возвращает массив названий директорий размера [size], находящихся внутри директории [path].
*/
config_str yon_file_list_dirs (char *path, int *size);
config_str yon_file_ls(char *path, int *size);
int yon_file_is_directory(const char *path);
/** yon_dir_get_contents(char *dir_path, int *size)
* [EN]
*

Loading…
Cancel
Save