示例#1
0
        public override ILoadedImage Load(Address?addrLoad)
        {
            var rdr     = new ByteImageReader(base.RawImage);
            var archive = new TarArchive(this.ImageLocation);

            for (; ;)
            {
                var tarHeader = rdr.ReadStruct <tar_header>();
                if (tarHeader.filename.All(b => b == 0))
                {
                    break;
                }
                if (PeekString(rdr, "ustar"))
                {
                    var ustarHeader = rdr.ReadStruct <ustar_header>();
                    Align(rdr, TarBlockSize);

                    var filename = TarFile.GetString(tarHeader.filename);
                    var file     = archive.AddFile(filename, (a, p, n) => TarFile.Load(a, p, n, tarHeader, ustarHeader, rdr));

                    rdr.Offset += file.Length;
                    Align(rdr, TarBlockSize);
                }
            }
            return(archive);
        }