using System;
namespace Pulsar.Client.Helper.HVNC
{
///
/// Represents the progress state while cloning a browser profile directory.
///
internal readonly struct BrowserCloneProgress
{
public BrowserCloneProgress(int filesCopied, int totalFiles, string currentItem, bool isIndeterminate = false)
{
FilesCopied = filesCopied;
TotalFiles = totalFiles;
CurrentItem = currentItem ?? string.Empty;
IsIndeterminate = isIndeterminate;
}
///
/// Gets the number of files copied so far.
///
public int FilesCopied { get; }
///
/// Gets the total number of files scheduled for cloning.
///
public int TotalFiles { get; }
///
/// Gets the relative path of the item currently being cloned.
///
public string CurrentItem { get; }
///
/// Indicates whether the operation is currently in an indeterminate state.
///
public bool IsIndeterminate { get; }
///
/// Gets the progress percentage (0-100) when the total file count is known.
///
public int Percent
{
get
{
if (TotalFiles <= 0)
{
return 0;
}
double raw = (double)FilesCopied / TotalFiles * 100d;
if (raw < 0d)
{
return 0;
}
if (raw > 100d)
{
return 100;
}
return (int)Math.Round(raw);
}
}
}
}