Skip to content

Commit 1b32335

Browse files
committed
its called a fork...
adds pr: (bloxstraplabs#3322)
1 parent b06bc39 commit 1b32335

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Bloxstrap/Utility/Filesystem.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@ namespace Bloxstrap.Utility
99
{
1010
internal static class Filesystem
1111
{
12-
internal static long GetFreeDiskSpace(string path)
12+
internal static long GetFreeDiskSpace(string p)
1313
{
14-
foreach (var drive in DriveInfo.GetDrives())
15-
{
16-
// https://github.com/bloxstraplabs/bloxstrap/issues/1648#issuecomment-2192571030
17-
if (path.ToUpperInvariant().StartsWith(drive.Name))
14+
try {
15+
if (!Path.IsPathRooted(p) || !Path.IsPathFullyQualified(p)) {
16+
return -1;
17+
}
18+
var root = Path.GetPathRoot(p);
19+
if (root != null) {
20+
var drive = new DriveInfo(root);
1821
return drive.AvailableFreeSpace;
22+
} else {
23+
throw new ArgumentException("Invalid path", nameof(p));
24+
}
25+
} catch (ArgumentException e) {
26+
App.Logger.WriteLine("Filesystem::BadPath", $"The path: {e} does not contain valid drive info.");
27+
return -1;
1928
}
20-
21-
return -1;
2229
}
2330

2431
internal static void AssertReadOnly(string filePath)

0 commit comments

Comments
 (0)