Skip to content

Interface IFileSource

Namespace: Apogee.Content.FileSystem
Assembly: Apogee.Content.dll

A folder, a zip file or a pack that a mounts. Paths are relative to the source: canonical, with /, no leading slash, and the empty string for the source's root (see ). Reads are safe from several threads.

public interface IFileSource

Properties

CanWrite

bool CanWrite { get; }

Property Value

bool

Description

What the source is, for messages: a folder's path, a zip's file name.

string Description { get; }

Property Value

string

Methods

CreateDirectory(string)

void CreateDirectory(string path)

Parameters

path string

Delete(string)

Deletes a file, or a folder with what is in it. Does nothing when there is none.

void Delete(string path)

Parameters

path string

Kind(string)

FileKind Kind(string path)

Parameters

path string

Returns

FileKind

List(string, List<(string Name, FileKind Kind)>)

Adds the entries directly inside directory to into: their names and kinds, in any order (a source may list entries).

void List(string directory, List<(string Name, FileKind Kind)> into)

Parameters

directory string

into List<(string Name, FileKind Kind)>

Move(string, string)

Moves a file inside this source to a path that has no file yet, making the folders above it. A source that can move without copying (a folder: one rename) overrides this; the default copies and then deletes, which is what a source that only reads and writes whole files can do.

void Move(string source, string target)

Parameters

source string

target string

Exceptions

FileNotFoundException

There is no file at source.

IOException

There is already a file at target.

OpenRead(string)

Stream OpenRead(string path)

Parameters

path string

Returns

Stream

Exceptions

FileNotFoundException

There is no such file.

PhysicalPath(string)

The path in the real file system, when there is one: for watching a file or handing it to a library that wants a path.

string? PhysicalPath(string path)

Parameters

path string

Returns

string?

ReadAllBytes(string)

byte[] ReadAllBytes(string path)

Parameters

path string

Returns

byte[]

Exceptions

FileNotFoundException

There is no such file.

WriteAllBytes(string, ReadOnlySpan<byte>)

Writes the file whole, making the folders above it; an interrupted write leaves the old file.

void WriteAllBytes(string path, ReadOnlySpan<byte> bytes)

Parameters

path string

bytes ReadOnlySpan<byte>