Avoid running into problems from a GC hole in runtimes that don't support fast span.

Support for .NET Framework probably needs to be removed soon. Having runtime support for CreateSpan has turned out to be rather useful.
This commit is contained in:
Alex Barney 2019-11-23 21:05:37 -06:00
parent 2f6b75a8eb
commit abce62dd4f
2 changed files with 4 additions and 2 deletions

View file

@ -111,13 +111,14 @@ namespace LibHac.Fs
bool ignoreCase = searchOptions.HasFlag(SearchOptions.CaseInsensitive);
bool recurse = searchOptions.HasFlag(SearchOptions.RecurseSubdirectories);
DirectoryEntry dirEntry = default;
fs.OpenDirectory(out DirectoryHandle sourceHandle, path, OpenDirectoryMode.All).ThrowIfFailure();
using (sourceHandle)
{
while (true)
{
DirectoryEntry dirEntry = default;
fs.ReadDirectory(out long entriesRead, SpanHelpers.AsSpan(ref dirEntry), sourceHandle);
if (entriesRead == 0) break;

View file

@ -79,12 +79,13 @@ namespace LibHac.FsSystem
bool recurse = searchOptions.HasFlag(SearchOptions.RecurseSubdirectories);
IFileSystem fs = fileSystem;
DirectoryEntry dirEntry = default;
fileSystem.OpenDirectory(out IDirectory directory, path, OpenDirectoryMode.All).ThrowIfFailure();
while (true)
{
DirectoryEntry dirEntry = default;
directory.Read(out long entriesRead, SpanHelpers.AsSpan(ref dirEntry)).ThrowIfFailure();
if (entriesRead == 0) break;