diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-04-11 18:39:30 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-04-11 18:39:30 -0400 |
commit | 923690add35ef0c62cc169afbb651a6957eb75c2 (patch) | |
tree | d47b974396890a7c4f3e4b1bd01386eb96542522 /ls.c | |
parent | ab17e87f7becf9f3e7e48c554a1644c5a0271280 (diff) |
fix sort by size and printing times
Diffstat (limited to 'ls.c')
-rw-r--r-- | ls.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -112,7 +112,7 @@ static int ls_compare_files(const void *op_a, const void *op_b) int ret = 0; switch (sort) { case SIZE: - ret = a->st.st_size - b->st.st_size; + ret = b->st.st_size - a->st.st_size; break; case CTIME: @@ -353,7 +353,13 @@ static void ls_print_long(size_t n, struct file_info files[static n]) printf("%*ju ", SIZEWIDTH, (uintmax_t)st.st_size); } - printf("%s ", ls_file_time(st.st_mtim)); + if (sort == ATIME) { + printf("%s ", ls_file_time(st.st_atim)); + } else if (sort == CTIME) { + printf("%s ", ls_file_time(st.st_ctim)); + } else { + printf("%s ", ls_file_time(st.st_mtim)); + } char * name = ls_filename(files + i); if (S_ISLNK(st.st_mode)) { |