using System.IO;
namespace UVC.Util
{
///
/// DriveUtil 클래스는 시스템 드라이브의 가용 공간을 계산하는 유틸리티를 제공합니다.
///
public static class DriveUtil
{
///
/// 지정된 드라이브의 가용 GigaByte 크기를 반환합니다.
///
/// 드라이브 이름 (예: "C"). 기본값은 "C"입니다.
/// 가용 공간(GigaByte) 또는 드라이브가 없을 경우 -1을 반환합니다.
///
/// // Example usage:
/// long freeSpace = DriveUtil.GetDriveGigaBytes("C");
/// if (freeSpace != -1)
/// {
/// Debug.Log($"C 드라이브의 가용 공간: {freeSpace} GB");
/// }
/// else
/// {
/// Debug.LogError("드라이브를 찾을 수 없습니다.");
/// }
///
public static long GetDriveGigaBytes(string driveName = "C")
{
DriveInfo[] drivers = DriveInfo.GetDrives();
foreach (var item in drivers)
{
if (item.DriveType == DriveType.Fixed)
{
if (item.Name.StartsWith(driveName))
{
return item.AvailableFreeSpace / 1024 / 1024 / 1024;
}
}
}
return -1;
}
}
}