Vixen
dd8b0a81
csharp
public sealed class MemoryFileProvider

A file system that is a dictionary.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The default provider for tests, and — since Testing/TestApp.cs landed — the one TestApp mounts at /app, /data, /cache and /temp. ⚠ That sentence was here before the type was, in the present tense, and for months named a caller that had never existed; it is true now, and the reason it was written is that of the four parts doc 12 specifies a TestApp to have — a Null-backed host, this, a fake clock and a synthetic input source — this one was never the work. A test that touches the real filesystem is a test that can fail because of a virus scanner, a slow disk, or another test running at the same time, and none of those are the thing under test.

It is also the reference implementation. Every behaviour the interface promises — case-sensitivity, parent creation, deleting only empty directories — is implemented here in a few lines with nothing platform-specific in the way, so a disagreement between this and PhysicalFileProvider is a bug in the latter.

Fields and properties (2)

  • public bool IsReadOnly

    Whether this provider refuses every write.

  • public int FileCount

    How many files are stored.

Methods (16)

  • public MemoryFileProvider()

    Creates an empty, writable provider.

  • public MemoryFileProvider(bool isReadOnly)

    Creates an empty provider.

  • public void Seed(VirtualPath path, ReadOnlySpan<byte> contents)

    Adds or replaces a file. Ignores IsReadOnly, because seeding is not writing.

  • public void Seed(VirtualPath path, string contents)

    Adds or replaces a file from UTF-8 text.

  • public bool Exists(VirtualPath path)

    Whether a file or directory exists.

  • public bool TryGetEntry(VirtualPath path, out FileEntry entry)

    Reads what is known about a file or directory without opening it.

  • public IEnumerable<FileEntry> Enumerate(VirtualPath directory, bool recursive = false)

    Lists the contents of a directory.

  • public ValueTask<Stream> OpenReadAsync(VirtualPath path, CancellationToken cancellationToken = default(CancellationToken))

    Opens a file for reading.

  • public ValueTask<Stream> OpenWriteAsync(VirtualPath path, CancellationToken cancellationToken = default(CancellationToken))

    Opens a file for writing, creating or truncating it.

  • public Stream OpenRead(VirtualPath path)

    Opens a file for reading.

  • public Stream OpenWrite(VirtualPath path)

    Opens a file for writing, creating or truncating it.

  • public ValueTask<Stream> OpenAppendAsync(VirtualPath path, CancellationToken cancellationToken = default(CancellationToken))

    Opens a file for writing at its end, creating it if it is not there.

  • public Stream OpenAppend(VirtualPath path)

    Opens a file for writing at its end, creating it if it is not there.

  • public bool Delete(VirtualPath path)

    Deletes a file, or an empty directory.

  • public void CreateDirectory(VirtualPath path)

    Creates a directory and any missing parents.

  • public bool TryMap(VirtualPath path, out IMappedFile? mapped)

    Maps a file into memory, if this provider can.

Used by (70, showing 40)

  • AuthoredContentMmo.Content.Tests
  • ContentAddressablesRemote
  • AssetMaterialSourceTestsVixen.Engine.Renderer.Tests
  • AssetTerrainSourceTestsVixen.Engine.Renderer.Tests
  • AssetTextureSourceTestsVixen.Engine.Renderer.Tests
  • AssetTextureStreamingTestsVixen.Engine.Renderer.Tests
  • AssetWaterSourceTestsVixen.Engine.Renderer.Tests
  • CacheWorldVixen.Assets.Tests
  • CommitOnDisposeStreamVixen.Core.IO
  • CompositorContentTestsVixen.Assets.Tests
  • ContentReferenceTestsVixen.Assets.Tests
  • MemoryFileProviderConformanceVixen.Core.IO.Tests
  • MinimalFileProviderConformanceVixen.Core.IO.Tests
  • ObjectDatabaseTestsVixen.Core.Serialization.Tests
  • ReferenceWorldVixen.Assets.Tests
  • RemoteContentTestsVixen.Assets.Tests
  • RemoteWorldVixen.Assets.Tests
  • ShippedVixen.Net.Engine.Content.Tests
  • StreamedContentTestsVixen.Assets.Tests
  • TextureDemandTestsVixen.Engine.Renderer.Tests
  • UpdateWorldVixen.Assets.Tests
  • VirtualFileSystemTestsVixen.Core.IO.Tests
  • WorldVixen.Assets.Tests
  • WorldRendererTestsVixen.Engine.Renderer.Tests
  • AnimationClipImporterTestsVixen.Editor.Assets.Tests
  • AudioImporterTestsVixen.Editor.Assets.Tests
  • ChunksVixen.Editor.Assets.Tests
  • ClipMetadataTestsVixen.Editor.Assets.Tests
  • ConstraintAuthoringImporterTestsVixen.Editor.Assets.Tests
  • ContentBuilderTestsVixen.Editor.Assets.Tests
  • ContentMountTestsVixen.App.Tests
  • CreateMenuTestsVixen.Editor.App.Tests
  • CubeLutTestsVixen.Editor.Assets.Tests
  • DdsImportTestsVixen.Editor.Assets.Tests
  • DefinitionImporterTestsVixen.Editor.Assets.Tests
  • HarnessPlanImporterTestsVixen.Editor.Assets.Tests
  • HdrImportTestsVixen.Editor.Assets.Tests
  • HostedRendererTestsVixen.App.Tests
  • ImportBudgetTestsVixen.Editor.Assets.Tests
  • ImportParallelismTestsVixen.Editor.Assets.Tests