Class DiskSpace
Free space and directory sizes for the copies a native run makes. A run that copies a game install needs room for the whole copy; refusing before the copy starts says which drive and how much, where a full drive part-way through a copy leaves a half-made runtime behind and a confusing I/O error.
public static class DiskSpace
- Inheritance
-
objectDiskSpace
Methods
Available(string)
The free bytes on the drive that holds path (or would hold it: the nearest existing parent
decides), or null when the system cannot say, as for a Windows network share.
public static long? Available(string path)
Parameters
pathstring
Returns
- long?
DirectoryBytes(string)
The bytes of every file under directory, or 0 when it does not exist. Links are not followed.
public static long DirectoryBytes(string directory)
Parameters
directorystring
Returns
- long
Format(long)
Bytes as a short human figure: "812 MB", "2.3 GB".
public static string Format(long bytes)
Parameters
byteslong
Returns
- string
Headroom(long)
Room kept free beyond the estimate: 2 GiB, or a tenth of the estimate when that is larger.
public static long Headroom(long bytes)
Parameters
byteslong
Returns
- long
Require(string, long, string)
Refuses, before anything is copied, unless the drive that will hold target has
bytes free plus Headroom(long). The message names the drive, both amounts and what needed them.
Returns the free bytes it saw, or null when the drive's free space is unknown (then nothing is refused).
public static long? Require(string target, long bytes, string purpose)
Parameters
targetstringbyteslongpurposestring
Returns
- long?