delphidabbler / gbg

A Windows command line program to create a file of a given size, filled with garbage.
https://delphidabbler.com/software/gbg
MIT License
3 stars 0 forks source link

Permit file sizes to be specified using KB, MiB etc. #17

Open delphidabbler opened 2 weeks ago

delphidabbler commented 2 weeks ago

It would be easier in many cases to be able to specify file sizes in IEC standard quantities as follows:

Number of bytes IEC symbol Name
1,000 kB kilobyte
1,000^2 MB megabyte
1,000^3 GB gigabyte
1,024 KiB kibibyte
1,024^2 MiB mebibyte
1,024^3 GiB gibibyte

So, specifying 4KiB would be the same as specifying 4,096 and 4kB would convert to 4,000.

Rules:

  1. no space between the number and symbol, so 4KiB would be correct but 4 KiB would not.
  2. case is ignored so KB is the same as kB and KB.

Suggest not supported terabytes or tebibytes and larger quantities.

delphidabbler commented 2 weeks ago

Could implement this via a lookup table (dictionary) where IEC symbol is mapped to byte multiplier, e.g. "KiB" gets mapped to 1024.