fix go back doesnt work after going trash + TESTING SORT

This commit is contained in:
Night Kaly 2024-04-07 21:25:58 +00:00
parent 00e9ab4555
commit d6d0fd671a
Signed by: night0721
GPG key ID: 957D67B8DB7A119B

20
ccc.c
View file

@ -34,6 +34,7 @@ void edit_file();
void toggle_executable();
char *replace_home(char *str);
int write_last_d();
void sort_files();
void create_file();
void delete_files();
void wpprintw(const char *fmt, ...);
@ -280,8 +281,15 @@ int main(int argc, char** argv)
/* go to the trash dir */
case 't':;
char *trash_dir = check_trash_dir();
if (trash_dir != NULL)
if (trash_dir != NULL) {
strcpy(p_cwd, cwd);
change_dir(trash_dir, 0, 0);
}
break;
/* sort files */
case 'u':
sort_files();
break;
/* show directories' sizes */
@ -941,6 +949,16 @@ int write_last_d()
return 0;
}
int sort_compare(const void *a, const void *b) {
return strcmp(((file *) a)->name, ((file *) b)->name);
}
void sort_files()
{
qsort(files->items, files->length, sizeof(file), sort_compare);
highlight_current_line();
}
void create_file()
{
echo();