Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Bloxstrap/Utility/Filesystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ internal static class Filesystem
{
internal static long GetFreeDiskSpace(string path)
{
foreach (var drive in DriveInfo.GetDrives())
try
{
// https://github.com/bloxstraplabs/bloxstrap/issues/1648#issuecomment-2192571030
if (path.ToUpperInvariant().StartsWith(drive.Name))
return drive.AvailableFreeSpace;
var isUri = Uri.TryCreate(p, UriKind.RelativeOrAbsolute, out var u);
if (!Path.IsPathRooted(p) || !Path.IsPathFullyQualified(p) || (isUri && (u?.IsUnc??false)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation here

{
return -1;
}
var drive = new DriveInfo(p);
return drive.AvailableFreeSpace;
}

return -1;
catch (ArgumentException e)
{
App.Logger.WriteLine("Filesystem::BadPath", $"The path: {p} does not contain a valid drive info.");
return -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;, code won't compile.

}
}

internal static void AssertReadOnly(string filePath)
Expand Down