basic sorting implemented, segfaults in natural sort
This commit is contained in:
14
backend.c
14
backend.c
@ -5,6 +5,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "defines.h"
|
||||
#include "sorting.h"
|
||||
|
||||
extern unsigned int settings;
|
||||
extern unsigned int file_modifiers;
|
||||
@ -13,6 +14,7 @@ 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);
|
||||
*longest_name = 256; //magic number originates out of readdir(), unless i implement my own name size function, thisll do
|
||||
@ -58,18 +60,6 @@ void print_dir(WINDOW *win, char **dir_content){
|
||||
}
|
||||
}
|
||||
|
||||
// Comparison function to sort strings in ascending order
|
||||
int compare(const void *a, const void *b) {
|
||||
return strcasecmp(a, b);
|
||||
}
|
||||
void sort_dir(unsigned long *file_count, unsigned long *longest_name, char **dir_content){
|
||||
char content[*file_count][*longest_name];
|
||||
memset(content,0,sizeof(content));
|
||||
if ((file_modifiers & FILE_MODIFIERS_SORT_BITMASK) == 0) {//natural; first dirs, then files
|
||||
qsort(dir_content, *file_count, *longest_name, compare);
|
||||
}
|
||||
|
||||
}
|
||||
void *populate_dir(void *which){ // 0=left, 1=main, 2=right
|
||||
char wh = (char)which;
|
||||
unsigned long file_count = 0;
|
||||
|
Reference in New Issue
Block a user