in src/managed/DiffGen/ArchiveUtility/ArchiveLoader.cs [102:136]
public static bool TryLoadArchive(ArchiveLoaderContext context, out ArchiveTokenization tokens, params string[] typesToTry)
{
foreach (var typesWithPriorityByName in ArchiveTypesByPriority.Values)
{
foreach (Type type in typesWithPriorityByName.Values)
{
if (context.CancellationToken != CancellationToken.None)
{
context.CancellationToken.ThrowIfCancellationRequested();
}
var ctor = type.GetConstructor(new[] { typeof(ArchiveLoaderContext) });
var archive = (IArchive)ctor.Invoke(new object[] { context });
// Allows for selective loading of classes of archives only - this way we can look
// for a basic type while trying to load a composite type such as a SWUpdate file which
// is a cpio archive containing a specific layout.
// We can call ArchiveLoader(stream, "cpio", out tokens) in the SWUpdate Archive
// implementation to determine if a given stream is a cpio archive and then use
// that tokenization to determine if the layout matches.
if (typesToTry.Length != 0 && typesToTry.All(t => !t.Equals(archive.ArchiveType)))
{
continue;
}
if (TryLoadArchive(context, out tokens, archive))
{
return true;
}
}
}
tokens = null;
return false;
}