InMemoryFileSystemBackend Class
A FileSystemBackend that keeps the files in memory: the default backend of the browsing contexts (see BrowsingContextOptions.FileSystem). It is thread-safe, and can be shared by several browsing contexts.
public sealed class InMemoryFileSystemBackend : FileSystemBackend- Inheritance
FileSystemBackendInMemoryFileSystemBackend
Constructors
| Name | Description |
|---|---|
| InMemoryFileSystemBackend() |
InMemoryFileSystemBackend()
InMemoryFileSystemBackend.cspublic InMemoryFileSystemBackend()No documentation is available.
Methods
| Name | Description |
|---|---|
| CreateEntry(string, IReadOnlyList<string>, FileSystemHandleKind, long) | Creates an empty file or an empty directory, and returns true; returns false when its parent directory does not exist or when an entry already has its name. |
| GetEntries(string, IReadOnlyList<string>) | Returns the entries of a directory (in any order), or null when the directory does not exist. |
| GetEntryKind(string, IReadOnlyList<string>) | Returns the kind of the entry at a path, or null when there is none. |
| GetFileInfo(string, IReadOnlyList<string>) | Returns the size and the modification timestamp of a file, or null when the file does not exist. |
| GetUsage(string) | Returns an estimation of the number of bytes used by the file system of an origin (navigator.storage.estimate()). The default is 0: the usage is not reported. |
| MoveFile(string, IReadOnlyList<string>, IReadOnlyList<string>) | Moves a file to another path (another name, another directory, or both), replacing the file that has the new path when there is one, and returns true; returns false when the file or the new parent directory does not exist, or when the new path is the one of a directory. |
| ReadFile(string, IReadOnlyList<string>, long, Span<byte>) | Reads bytes of a file from a position, and returns the number of bytes read (less than the length of the buffer at the end of the file; 0 when the file does not exist). |
| RemoveEntry(string, IReadOnlyList<string>) | Removes a file, or a directory with all its entries, and returns true; returns false when the entry does not exist. The root directory is emptied, not removed. |
| ReplaceFileContent(string, IReadOnlyList<string>, ReadOnlyMemory<byte>, long) | Replaces the content of a file atomically (a writable stream is closed), and returns true; returns false when the file does not exist. |
| SetFileSize(string, IReadOnlyList<string>, long, long) | Sets the size of a file: the file is truncated, or grows with zeros. |
| WriteFile(string, IReadOnlyList<string>, long, ReadOnlySpan<byte>, long) | Writes bytes into a file at a position (the access handles write in place): the file grows when the bytes end after its end, and the bytes between its end and a greater position are zeros. |
CreateEntry(string, IReadOnlyList<string>, FileSystemHandleKind, long)
InMemoryFileSystemBackend.csCreates an empty file or an empty directory, and returns true; returns false when its parent directory does not exist or when an entry already has its name.
public override bool CreateEntry(string origin, IReadOnlyList<string> path, FileSystemHandleKind kind, long modificationTime)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the new entry.
kindFileSystemHandleKind- The kind of the entry.
modificationTimelong- The modification timestamp of a new file, in milliseconds since the Unix epoch.
Returns
GetEntries(string, IReadOnlyList<string>)
InMemoryFileSystemBackend.csReturns the entries of a directory (in any order), or null when the directory does not exist.
public override IReadOnlyList<FileSystemEntry>? GetEntries(string origin, IReadOnlyList<string> path)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the directory (empty for the root directory).
Returns
GetEntryKind(string, IReadOnlyList<string>)
InMemoryFileSystemBackend.csReturns the kind of the entry at a path, or null when there is none.
public override FileSystemHandleKind? GetEntryKind(string origin, IReadOnlyList<string> path)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the entry (empty for the root directory).
Returns
GetFileInfo(string, IReadOnlyList<string>)
InMemoryFileSystemBackend.csReturns the size and the modification timestamp of a file, or null when the file does not exist.
public override FileSystemFileInfo? GetFileInfo(string origin, IReadOnlyList<string> path)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the file.
Returns
GetUsage(string)
InMemoryFileSystemBackend.csMoveFile(string, IReadOnlyList<string>, IReadOnlyList<string>)
InMemoryFileSystemBackend.csMoves a file to another path (another name, another directory, or both), replacing the file that has the new path when there is one, and returns true; returns false when the file or the new parent directory does not exist, or when the new path is the one of a directory.
public override bool MoveFile(string origin, IReadOnlyList<string> path, IReadOnlyList<string> newPath)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the file.
newPathIReadOnlyList<string>- The new path of the file.
Returns
ReadFile(string, IReadOnlyList<string>, long, Span<byte>)
InMemoryFileSystemBackend.csReads bytes of a file from a position, and returns the number of bytes read (less than the length of the buffer at the end of the file; 0 when the file does not exist).
public override int ReadFile(string origin, IReadOnlyList<string> path, long position, Span<byte> buffer)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the file.
positionlong- The position of the first byte to read.
bufferSpan<byte>- The buffer to fill.
Returns
RemoveEntry(string, IReadOnlyList<string>)
InMemoryFileSystemBackend.csRemoves a file, or a directory with all its entries, and returns true; returns false when the entry does not exist. The root directory is emptied, not removed.
public override bool RemoveEntry(string origin, IReadOnlyList<string> path)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the entry.
Returns
ReplaceFileContent(string, IReadOnlyList<string>, ReadOnlyMemory<byte>, long)
InMemoryFileSystemBackend.csReplaces the content of a file atomically (a writable stream is closed), and returns true; returns false when the file does not exist.
public override bool ReplaceFileContent(string origin, IReadOnlyList<string> path, ReadOnlyMemory<byte> content, long modificationTime)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the file.
contentReadOnlyMemory<byte>- The new content.
modificationTimelong- The new modification timestamp of the file, in milliseconds since the Unix epoch.
Returns
SetFileSize(string, IReadOnlyList<string>, long, long)
InMemoryFileSystemBackend.csSets the size of a file: the file is truncated, or grows with zeros.
public override void SetFileSize(string origin, IReadOnlyList<string> path, long size, long modificationTime)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the file.
sizelong- The new size.
modificationTimelong- The new modification timestamp of the file, in milliseconds since the Unix epoch.
WriteFile(string, IReadOnlyList<string>, long, ReadOnlySpan<byte>, long)
InMemoryFileSystemBackend.csWrites bytes into a file at a position (the access handles write in place): the file grows when the bytes end after its end, and the bytes between its end and a greater position are zeros.
public override void WriteFile(string origin, IReadOnlyList<string> path, long position, ReadOnlySpan<byte> data, long modificationTime)Parameters
originstring- The serialization of the origin.
pathIReadOnlyList<string>- The path of the file.
positionlong- The position of the first byte to write.
dataReadOnlySpan<byte>- The bytes to write.
modificationTimelong- The new modification timestamp of the file, in milliseconds since the Unix epoch.