Compare commits

...

3 Commits

Author SHA1 Message Date
cryolithic
18ec23df5a
Merge 1e3f76a2fd into dbdd0e37d6 2025-03-30 01:08:08 +08:00
Matt
dbdd0e37d6
Cancel parenthesis in ExtractZip regex (#4968)
Some checks failed
CI (Debug) / build (push) Has been cancelled
CI (Release) / build (push) Has been cancelled
CI (Release) / release (push) Has been cancelled
CI (Release) / release-test (push) Has been cancelled
2025-03-29 09:00:02 +00:00
Cryolithic
1e3f76a2fd Update Filesystem.cs
Made disk space check more reliable.
2024-10-18 14:53:41 -07:00
2 changed files with 14 additions and 7 deletions

View File

@ -1525,7 +1525,7 @@ namespace Bloxstrap
var regexList = new List<string>(); var regexList = new List<string>();
foreach (string file in files) foreach (string file in files)
regexList.Add("^" + file.Replace("\\", "\\\\") + "$"); regexList.Add("^" + file.Replace("\\", "\\\\").Replace("(", "\\(").Replace(")", "\\)") + "$");
fileFilter = String.Join(';', regexList); fileFilter = String.Join(';', regexList);
} }

View File

@ -11,14 +11,21 @@ namespace Bloxstrap.Utility
{ {
internal static long GetFreeDiskSpace(string path) internal static long GetFreeDiskSpace(string path)
{ {
foreach (var drive in DriveInfo.GetDrives()) try
{ {
// https://github.com/bloxstraplabs/bloxstrap/issues/1648#issuecomment-2192571030 var isUri = Uri.TryCreate(p, UriKind.RelativeOrAbsolute, out var u);
if (path.ToUpperInvariant().StartsWith(drive.Name)) if (!Path.IsPathRooted(p) || !Path.IsPathFullyQualified(p) || (isUri && (u?.IsUnc??false)))
return drive.AvailableFreeSpace; {
return -1;
}
var drive = new DriveInfo(p);
return drive.AvailableFreeSpace;
} }
catch (ArgumentException e)
return -1; {
App.Logger.WriteLine("Filesystem::BadPath", $"The path: {p} does not contain a valid drive info.");
return -1
}
} }
internal static void AssertReadOnly(string filePath) internal static void AssertReadOnly(string filePath)