77#include "modules/disk/disk.h"
88#include "util/stringUtils.h"
99
10- #define FF_DISK_NUM_FORMAT_ARGS 12
10+ #define FF_DISK_NUM_FORMAT_ARGS 14
1111#pragma GCC diagnostic ignored "-Wsign-conversion"
1212
1313static void printDisk (FFDiskOptions * options , const FFDisk * disk )
@@ -104,11 +104,16 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
104104 }
105105 else
106106 {
107- FF_STRBUF_AUTO_DESTROY bytesPercentageStr = ffStrbufCreate ();
108- ffPercentAppendNum (& bytesPercentageStr , bytesPercentage , options -> percent , false, & options -> moduleArgs );
109- FF_STRBUF_AUTO_DESTROY filesPercentageStr = ffStrbufCreate ();
107+ FF_STRBUF_AUTO_DESTROY bytesPercentageNum = ffStrbufCreate ();
108+ ffPercentAppendNum (& bytesPercentageNum , bytesPercentage , options -> percent , false, & options -> moduleArgs );
109+ FF_STRBUF_AUTO_DESTROY bytesPercentageBar = ffStrbufCreate ();
110+ ffPercentAppendBar (& bytesPercentageBar , bytesPercentage , options -> percent , & options -> moduleArgs );
111+
110112 double filesPercentage = disk -> filesTotal > 0 ? ((double ) disk -> filesUsed / (double ) disk -> filesTotal ) * 100.0 : 0 ;
111- ffPercentAppendNum (& filesPercentageStr , filesPercentage , options -> percent , false, & options -> moduleArgs );
113+ FF_STRBUF_AUTO_DESTROY filesPercentageNum = ffStrbufCreate ();
114+ ffPercentAppendNum (& filesPercentageNum , filesPercentage , options -> percent , false, & options -> moduleArgs );
115+ FF_STRBUF_AUTO_DESTROY filesPercentageBar = ffStrbufCreate ();
116+ ffPercentAppendBar (& filesPercentageBar , filesPercentage , options -> percent , & options -> moduleArgs );
112117
113118 bool isExternal = !!(disk -> type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT );
114119 bool isHidden = !!(disk -> type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT );
@@ -117,16 +122,18 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
117122 FF_PRINT_FORMAT_CHECKED (key .chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_NO_CUSTOM_KEY , FF_DISK_NUM_FORMAT_ARGS , ((FFformatarg []) {
118123 {FF_FORMAT_ARG_TYPE_STRBUF , & usedPretty , "size-used" },
119124 {FF_FORMAT_ARG_TYPE_STRBUF , & totalPretty , "size-total" },
120- {FF_FORMAT_ARG_TYPE_STRBUF , & bytesPercentageStr , "size-percentage" },
125+ {FF_FORMAT_ARG_TYPE_STRBUF , & bytesPercentageNum , "size-percentage" },
121126 {FF_FORMAT_ARG_TYPE_UINT , & disk -> filesUsed , "files-used" },
122127 {FF_FORMAT_ARG_TYPE_UINT , & disk -> filesTotal , "files-total" },
123- {FF_FORMAT_ARG_TYPE_STRBUF , & filesPercentageStr , "files-percentage" },
128+ {FF_FORMAT_ARG_TYPE_STRBUF , & filesPercentageNum , "files-percentage" },
124129 {FF_FORMAT_ARG_TYPE_BOOL , & isExternal , "is-external" },
125130 {FF_FORMAT_ARG_TYPE_BOOL , & isHidden , "is-hidden" },
126131 {FF_FORMAT_ARG_TYPE_STRBUF , & disk -> filesystem , "filesystem" },
127132 {FF_FORMAT_ARG_TYPE_STRBUF , & disk -> name , "name" },
128133 {FF_FORMAT_ARG_TYPE_BOOL , & isReadOnly , "is-readonly" },
129134 {FF_FORMAT_ARG_TYPE_STRING , ffTimeToShortStr (disk -> createTime ), "create-time" },
135+ {FF_FORMAT_ARG_TYPE_STRBUF , & bytesPercentageBar , "size-percentage-bar" },
136+ {FF_FORMAT_ARG_TYPE_STRBUF , & filesPercentageBar , "files-percentage-bar" },
130137 }));
131138 }
132139}
@@ -430,16 +437,18 @@ void ffPrintDiskHelpFormat(void)
430437 FF_PRINT_MODULE_FORMAT_HELP_CHECKED (FF_DISK_MODULE_NAME , "{1} / {2} ({3}) - {9}" , FF_DISK_NUM_FORMAT_ARGS , ((const char * []) {
431438 "Size used - size-used" ,
432439 "Size total - size-total" ,
433- "Size percentage - size-percentage" ,
440+ "Size percentage num - size-percentage" ,
434441 "Files used - files-used" ,
435442 "Files total - files-total" ,
436- "Files percentage - files-percentage" ,
443+ "Files percentage num - files-percentage" ,
437444 "True if external volume - is-external" ,
438445 "True if hidden volume - is-hidden" ,
439446 "Filesystem - filesystem" ,
440447 "Label / name - name" ,
441448 "True if read-only - is-readonly" ,
442449 "Create time in local timezone - create-time" ,
450+ "Size percentage bar - size-percentage-bar" ,
451+ "Files percentage bar - files-percentage-bar" ,
443452 }));
444453}
445454
0 commit comments