#include #include #include #include #include extern unsigned int settings; 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){ DIR *dir = opendir(path); if (dir) { unsigned long index = 0; struct dirent *entry; while ( entry=readdir(dir) ) { if (entry->d_name[0] != '.' && !(settings & 1)) { //bit 0 = show_hidden_files index++; if ((unsigned long)sizeof(entry->d_name) > *longest_name) { *longest_name = sizeof(entry->d_name); } } else if (settings & 1){ //bit 0 = show_hidden_files 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){ 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] != '.' && !(settings & 1)) { //bit 0 = show_hidden_files strcpy(dir_content[index], entry->d_name); index++; } else if (settings & 1){ //bit 0 = show_hidden_files strcpy(dir_content[index], entry->d_name); index++; } } } closedir(dir); } void print_dir(WINDOW *win, char **dir_content){ for (unsigned long i = 0; i < (unsigned long)file_count; i++ ){ wprintw(win, "%s",dir_content[i]); 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); content_m = calloc(file_count, sizeof(*content_m)); for (unsigned long i = 0; i