Path.FindFreePath: Fixed bug when filename is stringview into target string

This commit is contained in:
Simon Lübeß
2025-07-10 13:29:32 +02:00
parent ecfe838ad4
commit 39a825634a
@@ -62,8 +62,10 @@ extension Path
{
int fileNumber = 0;
String wantedNameCopy = new:ScopedAlloc! .(wantedName);
String currentFileName = outFreeFilename ?? scope .();
currentFileName.SetF($"{wantedName}{fileExtension}");
currentFileName.SetF($"{wantedNameCopy}{fileExtension}");
while (true)
{
Path.Combine(outFreePath..Clear(), targetDirectory, currentFileName);
@@ -72,7 +74,7 @@ extension Path
break;
fileNumber++;
currentFileName.SetF($"{wantedName} ({fileNumber}){fileExtension}");
currentFileName.SetF($"{wantedNameCopy} ({fileNumber}){fileExtension}");
}
}
}