Vixen
02b45cc4
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 the one TestApp mounts (docs/plan/12-build-ci-and-testing.md). 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 (44, showing 40)

  • ContentAddressablesRemote
  • AssetMaterialSourceTestsVixen.Engine.Renderer.Tests
  • AssetTextureSourceTestsVixen.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
  • StreamedContentTestsVixen.Assets.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
  • HarnessPlanImporterTestsVixen.Editor.Assets.Tests
  • ImportPipelineTestsVixen.Editor.Assets.Tests
  • ImportedGeometryLoadsTestsVixen.Editor.Assets.Tests
  • ImporterTestsVixen.Editor.Assets.Tests
  • MaterialImporterTestsVixen.Editor.Assets.Tests
  • ModelImporterTestsVixen.Editor.Assets.Tests
  • MoveSetImporterTestsVixen.Editor.Assets.Tests
  • NativeFormatImporterTestsVixen.Editor.Assets.Tests
  • NavMeshImporterTestsVixen.Editor.Assets.Tests
  • PlannedProjectVixen.Editor.Assets.Tests
  • ProxyShapeImporterTestsVixen.Editor.Assets.Tests
  • RemoteContentMountTestsVixen.App.Tests
  • SceneImporterTestsVixen.Editor.Assets.Tests
  • ServedDirectoryVixen.ContentServer.Tests