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.
Signature
diskUsage(path: string): Result<DiskUsage, FsError>Fields
| Field | Type | Description |
|---|---|---|
total | u64 | Total disk space in bytes. |
used | u64 | Used disk space in bytes. |
free | u64 | Bytes 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