cex

C/Curses file EXplorer
git clone git://git.wimdupont.com/cex.git
Log | Files | Refs | README | LICENSE

commit a207920f7c01711eff793034ac74a1e262763c45
parent 34a175d207cbf65d0ffa85587a7b05974af6a881
Author: Wim Dupont <wim@wimdupont.com>
Date:   Fri, 25 Apr 2025 19:46:09 +0200

file size format configurable

Diffstat:
Mcex.c | 8++++----
Mconfig.def.h | 1+
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/cex.c b/cex.c @@ -99,7 +99,7 @@ static void make_open_default(void); static void make_mime_default(const char *mime, const char *app); static int rm_file(const char *fname); static int rename_file(const char *fname); -static char *human_readable_bytes(char *buf, intmax_t bytes, bool decimal); +static char *human_readable_bytes(char *buf, intmax_t bytes); static char *prompt_answer(char *buf, size_t size, const char *question); static char *cpstr(char *dest, const char *src); static char *get_file_info(char *buf, const char *filepath); @@ -719,7 +719,7 @@ get_file_info(char *buf, const char *filepath) mods, usr->pw_name, grp->gr_name, - human_readable_bytes(hrbytes, (intmax_t)statbuf.st_size, TRUE), + human_readable_bytes(hrbytes, (intmax_t) statbuf.st_size), datestr); return buf; @@ -1193,10 +1193,10 @@ is_dir(DirWin *dirwin, size_t index) } char * -human_readable_bytes(char *buf, intmax_t bytes, bool decimal) +human_readable_bytes(char *buf, intmax_t bytes) { double dblBytes = bytes; - int power = decimal ? 1000 : 1024; + int power = SIZE_DECIMAL_FORMAT ? 1000 : 1024; char *suffix[] = {"B", "KB", "MB", "GB", "TB"}; char length = sizeof(suffix) / sizeof(suffix[0]); int i = 0; diff --git a/config.def.h b/config.def.h @@ -2,6 +2,7 @@ #define CONFIG_H #define DEFAULT_HIDE TRUE +#define SIZE_DECIMAL_FORMAT FALSE #define MIME_MAX 255 #define MIME_APP_MAX 255 #define BORDER_SPACE_SIZE 2