Table of Contents

Class DiskSpace

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll

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
object
DiskSpace

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

path string

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

directory string

Returns

long

Format(long)

Bytes as a short human figure: "812 MB", "2.3 GB".

public static string Format(long bytes)

Parameters

bytes long

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

bytes long

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

target string
bytes long
purpose string

Returns

long?