Skip to content

Commit

Permalink
its called a fork...
Browse files Browse the repository at this point in the history
  • Loading branch information
lokzz committed Dec 30, 2024
1 parent b06bc39 commit 1b32335
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Bloxstrap/Utility/Filesystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ namespace Bloxstrap.Utility
{
internal static class Filesystem
{
internal static long GetFreeDiskSpace(string path)
internal static long GetFreeDiskSpace(string p)
{
foreach (var drive in DriveInfo.GetDrives())
{
// https://github.com/bloxstraplabs/bloxstrap/issues/1648#issuecomment-2192571030
if (path.ToUpperInvariant().StartsWith(drive.Name))
try {
if (!Path.IsPathRooted(p) || !Path.IsPathFullyQualified(p)) {
return -1;
}
var root = Path.GetPathRoot(p);
if (root != null) {
var drive = new DriveInfo(root);
return drive.AvailableFreeSpace;
} else {
throw new ArgumentException("Invalid path", nameof(p));
}
} catch (ArgumentException e) {
App.Logger.WriteLine("Filesystem::BadPath", $"The path: {e} does not contain valid drive info.");
return -1;
}

return -1;
}

internal static void AssertReadOnly(string filePath)
Expand Down

0 comments on commit 1b32335

Please sign in to comment.