You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Common/Disk/DriveInfoMount.cs

64 lines
1.7 KiB

using System.IO;
using System.IO.Abstractions;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Disk
{
public class DriveInfoMount : IMount
{
private readonly IDriveInfo _driveInfo;
private readonly DriveType _driveType;
public DriveInfoMount(IDriveInfo driveInfo, DriveType driveType = DriveType.Unknown, MountOptions mountOptions = null)
{
_driveInfo = driveInfo;
_driveType = driveType;
MountOptions = mountOptions;
}
public long AvailableFreeSpace => _driveInfo.AvailableFreeSpace;
public string DriveFormat => _driveInfo.DriveFormat;
public DriveType DriveType
{
get
{
if (_driveType != DriveType.Unknown)
{
return _driveType;
}
return _driveInfo.DriveType;
}
}
public bool IsReady => _driveInfo.IsReady;
public MountOptions MountOptions { get; private set; }
public string Name => _driveInfo.Name;
public string RootDirectory => _driveInfo.RootDirectory.FullName;
public long TotalFreeSpace => _driveInfo.TotalFreeSpace;
public long TotalSize => _driveInfo.TotalSize;
public string VolumeLabel => _driveInfo.VolumeLabel;
public string VolumeName
{
get
{
if (VolumeLabel.IsNullOrWhiteSpace() || VolumeLabel.StartsWith("UUID=") || Name == VolumeLabel)
{
return Name;
}
return string.Format("{0} ({1})", Name, VolumeLabel);
}
}
}
}