using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; using Duplicati.Proprietary.DiskImage.Partition; namespace Duplicati.Proprietary.DiskImage.Filesystem; public interface IFilesystem : IDisposable { /// /// Gets the parent partition. /// IPartition Partition { get; } /// /// Gets the filesystem type. /// FileSystemType Type { get; } /// /// Gets filesystem-specific metadata. E.g. for journal filesystems, this could be the journal file. /// /// Cancellation token. /// A task that resolves to filesystem-specific metadata. Task GetFilesystemMetadataAsync(CancellationToken cancellationToken); /// /// Lists top-level files in the filesystem. /// /// Cancellation token. /// A task that resolves to a collection of top-level files. IAsyncEnumerable ListFilesAsync(CancellationToken cancellationToken); /// /// Lists files in a directory. /// /// The directory to list files from. /// Cancellation token. /// A task that resolves to a collection of files in the specified directory. /// Thrown if is null. /// Thrown if is not a directory. IAsyncEnumerable ListFilesAsync(IFile directory, CancellationToken cancellationToken); Task OpenFileAsync(IFile file, CancellationToken cancellationToken); /// /// Opens a file for writing. Creates the file if it doesn't exist. /// /// The file to write to. If null, a new file will be created at the specified address. /// The address/offset to write to. /// The expected size of the file. /// Cancellation token. /// A stream for writing to the file. Task CreateFileAsync(IFile? file, long address, long size, CancellationToken cancellationToken); } public interface IFile { string? Path { get; } long? Address { get; } long Size { get; } bool IsDirectory { get; } } public interface IFileMetadata { byte[]? RawMetadata { get; } DateTimeOffset? Created { get; } DateTimeOffset? Modified { get; } DateTimeOffset? Accessed { get; } }