#include #include #include #include #include extern unsigned long longest_name; extern unsigned long file_count; extern char **content_l; extern char **content_m; extern char **content_r; extern char *path; void get_dir_size(char *path, unsigned long *file_count, unsigned long *longest_name, char show_hidden){ DIR *dir = opendir(path); if (dir) { unsigned long index = 0; struct dirent *entry; while ( entry=readdir(dir) ) { if (entry->d_name[0] != '.' && !show_hidden) { index++; if ((unsigned long)sizeof(entry->d_name) > *longest_name) { *longest_name = sizeof(entry->d_name); } } else if (show_hidden){ index++; if ((unsigned long*)sizeof(entry->d_name) > (unsigned long*)longest_name) { longest_name = (unsigned long*)sizeof(entry->d_name); } } } *file_count = index; } closedir(dir); } void get_dir_content(char *path, char **dir_content, char show_hidden){ DIR *dir = opendir(path); char content[file_count][longest_name]; memset(content,0,sizeof(content)); if (dir) { int index = 0; struct dirent *entry; while ( entry=readdir(dir) ) { if (entry->d_name[0] != '.' && !show_hidden) { strcpy(dir_content[index], entry->d_name); index++; } else if (show_hidden){ for (unsigned long i = 0; i < sizeof(entry->d_name)/sizeof(char); i++) { if ((entry->d_name[i]) != '\0'){ } else { break; } } index++; } } } closedir(dir); } void print_dir(WINDOW *win, char **dir_content){ char str[longest_name]; for (unsigned long i = 0; i < (unsigned long)file_count; i++ ){ strcpy(str, dir_content[i]); wprintw(win, "%s",str); wmove(win, i, 1); } } void *populate_dir(void *which){ // 0=left, 1=main, 2=right char wh = (char)which; if (wh) { if (wh==1) { get_dir_size(path, &file_count, &longest_name, 0); content_m = calloc(file_count, sizeof(*content_m)); for (unsigned long i = 0; i