2026-02-05 11:14:01 +01:00
|
|
|
// Copyright (c) 2026 Duplicati Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Duplicati.Library.Interface;
|
|
|
|
|
|
|
|
|
|
namespace Duplicati.Proprietary.DiskImage.SourceItems;
|
|
|
|
|
|
2026-02-15 12:45:59 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Base class for all disk image source entries.
|
|
|
|
|
/// Provides common implementation for entries in the disk image hierarchy.
|
|
|
|
|
/// </summary>
|
2026-02-05 11:14:01 +01:00
|
|
|
internal abstract class DiskImageEntryBase(string path) : ISourceProviderEntry
|
|
|
|
|
{
|
2026-02-15 12:45:59 +01:00
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual bool IsFolder => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual bool IsMetaEntry => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual bool IsRootEntry => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual DateTime CreatedUtc => DateTime.UnixEpoch;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual DateTime LastModificationUtc => DateTime.UnixEpoch;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public string Path => path;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual long Size => -1;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public bool IsSymlink => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public string? SymlinkTarget => null;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual FileAttributes Attributes => IsFolder ? FileAttributes.Directory : FileAttributes.Normal;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public bool IsBlockDevice => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public bool IsCharacterDevice => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public bool IsAlternateStream => false;
|
2026-02-15 12:45:59 +01:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public string? HardlinkTargetId => null;
|
|
|
|
|
|
2026-02-15 12:45:59 +01:00
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual Task<Stream> OpenRead(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
throw new NotSupportedException("This entry does not support reading.");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-15 12:45:59 +01:00
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public abstract IAsyncEnumerable<ISourceProviderEntry> Enumerate(CancellationToken cancellationToken);
|
|
|
|
|
|
2026-02-15 12:45:59 +01:00
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual Task<bool> FileExists(string filename, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(false);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-15 12:45:59 +01:00
|
|
|
/// <inheritdoc />
|
2026-02-05 11:14:01 +01:00
|
|
|
public virtual Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(new Dictionary<string, string?>());
|
|
|
|
|
}
|
|
|
|
|
}
|