namespace SharpCompress.Common;
///
/// Represents progress information for compression or extraction operations.
///
public sealed class ProgressReport
{
///
/// Initializes a new instance of the class.
///
/// The path of the entry being processed.
/// Number of bytes transferred so far.
/// Total bytes to be transferred, or null if unknown.
public ProgressReport(string entryPath, long bytesTransferred, long? totalBytes)
{
EntryPath = entryPath;
BytesTransferred = bytesTransferred;
TotalBytes = totalBytes;
}
///
/// Gets the path of the entry being processed.
///
public string EntryPath { get; }
///
/// Gets the number of bytes transferred so far.
///
public long BytesTransferred { get; }
///
/// Gets the total number of bytes to be transferred, or null if unknown.
///
public long? TotalBytes { get; }
///
/// Gets the progress percentage (0-100), or null if total bytes is unknown.
///
public double? PercentComplete =>
TotalBytes.HasValue && TotalBytes.Value > 0
? (double)BytesTransferred / TotalBytes.Value * 100
: null;
}