th/sorting.c
2025-05-10 22:30:52 +02:00

30 lines
683 B
C

#include <curses.h>
#include <dirent.h>
#include <strings.h>
#include "defines.h"
extern unsigned int settings;
extern unsigned int file_modifiers;
int skip_hidden_files(const struct dirent *entry){
if (entry->d_name[0] == '.') {
return 0;
}
return 1;
}
int sort_natural(const void *file0, const void *file1){
unsigned char file_type0 = ((file*)file0)->file_type;
unsigned char file_type1 = ((file*)file1)->file_type;
if (file_type0 > file_type1) {
return 1;
} else if (file_type0 < file_type1) {
return -1;
} else {
char *file_name0 = ((file*)file0)->file_name;
char *file_name1 = ((file*)file1)->file_name;
return strcasecmp(file_name0, file_name1);
}
}