using EvilEngine.Mounts; namespace EvilEngine.Adapters.UnityFs; public sealed class UnityFsContainer : IContainerAdapter { public string Id => "unityfs"; public bool Recognises(IFileSource parent, VirtualPath path) { if (!parent.TryOpen(path, out var stream)) return false; using (stream) { Span head = stackalloc byte[UnityFsArchive.Signature.Length]; return stream.ReadAtLeast(head, head.Length, false) == head.Length && UnityFsArchive.IsSignature(head); } } public IFileSource Open(IFileSource parent, VirtualPath path) { var location = $"{parent.Location}/{path}"; using var stream = parent.Open(path); return new UnityFsSource(location, UnityFsArchive.Read(stream, location), () => parent.OpenAccess(path)); } }