filesizes 1.1.0

Library for parsing, formatting, and generally working with file sizes.

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:


A library for parsing, formatting, and generally working with file sizes.


First, a simple example:

import filesizes;
import std.file : getSize;
import std.stdio;

void main() {
    ulong size = getSize("my-large-file.dat");
    writefln!"My file is %s"(formatFilesize(size));

Assuming my-large-file.dat is 92874 bytes, we will get the following output:

My file is 92.9 KB

You can provide additional settings to change how things are formatted:

string s = formatFilesize("%.3f", size, false, false);
writefln!"My file is %s"(s);

This will write the following:

My file is 90.687 Kibibytes


This library also provides methods to parse filesize expressions.

import filesizes;
import std.stdio;

void main() {
    string sizeStr = "45 gigabytes";
    writefln!"%s is equal to %d bytes"(sizeStr, parseFilesize(sizeStr));

This will write the following:

45 gigabytes is equal to 45000000000 bytes"

Please see the documentation for more details.

  • Andrew Lalis
1.1.0 2022-Mar-10
1.0.0 2022-Mar-08
~main 2022-Mar-10
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 8 downloads total

Short URL: