Skip to content

diskUsage ​

Returns disk usage information for the filesystem containing the given path. On Unix, free is the space available to this process according to statvfs; on Windows, it is the space available to the caller according to GetDiskFreeSpaceExW. used is the filesystem-wide used space, so used + free can be less than total.

SignaturediskUsage(path: string): Result<DiskUsage, FsError>

Fields ​

FieldTypeDescription
totalu64Total disk space in bytes.
usedu64Used disk space in bytes.
freeu64Bytes this process can still write. Space reserved for the superuser is not included, so used + free can be less than total.

Example ​

tyrus
import { diskUsage } from "tyrus:fs";

const usage = diskUsage(".");
print(usage.total); // e.g. 500107862016
print(usage.used); // e.g. 250053931008
print(usage.free); // e.g. 249850901760