ExtractEntry() 공개 메소드

public ExtractEntry ( CpioFileEntry entry, Stream outStream ) : void
entry CpioFileEntry
outStream Stream
리턴 void
예제 #1
0
        private void ExtractFirmwareArchive()
        {
            string ipod_package = null;

            foreach (DirectoryInfo directory in new DirectoryInfo(ResourcesPath).GetDirectories("iPod*.pkg"))
            {
                ipod_package = directory.FullName;
                break;
            }

            string cpio_out  = Path.Combine(work_base, "firmware.cpio");
            string gzcpio_in = Path.Combine(ipod_package,
                                            "Contents" + Path.DirectorySeparatorChar + "Archive.pax.gz");

            // this sucks, it seems necessary to create an extracted CPIO archive
            // because GZipInputStream can't do seeking... CPIO needs seeking

            FileStream      in_stream  = new FileStream(gzcpio_in, FileMode.Open, FileAccess.Read);
            FileStream      out_stream = new FileStream(cpio_out, FileMode.Create);
            GZipInputStream gzstream   = new GZipInputStream(in_stream);

            byte [] block = new byte[4096];
            int     size  = block.Length;

            while (true)
            {
                size = gzstream.Read(block, 0, size);
                if (size > 0)
                {
                    out_stream.Write(block, 0, size);
                }
                else
                {
                    break;
                }
            }

            in_stream.Close();
            out_stream.Close();

            CpioArchive archive = new CpioArchive(cpio_out);

            foreach (CpioFileEntry entry in archive)
            {
                string filename = Path.GetFileName(entry.FileName);
                if (filename.StartsWith("Firmware-"))
                {
                    string image_path = Path.Combine(firmware_export_path, filename);
                    archive.ExtractEntry(entry, image_path);
                    images.Add(image_path);
                }
            }

            File.Delete(cpio_out);
        }
예제 #2
0
        private void ExtractFirmwareArchive()
        {
            string ipod_package = null;

            foreach(DirectoryInfo directory in new DirectoryInfo(ResourcesPath).GetDirectories("iPod*.pkg")) {
                ipod_package = directory.FullName;
                break;
            }

            string cpio_out = Path.Combine(work_base, "firmware.cpio");
            string gzcpio_in = Path.Combine(ipod_package,
                "Contents" + Path.DirectorySeparatorChar + "Archive.pax.gz");

            // this sucks, it seems necessary to create an extracted CPIO archive
            // because GZipInputStream can't do seeking... CPIO needs seeking

            FileStream in_stream = new FileStream(gzcpio_in, FileMode.Open, FileAccess.Read);
            FileStream out_stream = new FileStream(cpio_out, FileMode.Create);
            GZipInputStream gzstream = new GZipInputStream(in_stream);

            byte [] block = new byte[4096];
            int size = block.Length;

            while(true) {
                size = gzstream.Read(block, 0, size);
                if(size > 0) {
                    out_stream.Write(block, 0, size);
                } else {
                    break;
                }
            }

            in_stream.Close();
            out_stream.Close();

            CpioArchive archive = new CpioArchive(cpio_out);
            foreach(CpioFileEntry entry in archive) {
                string filename = Path.GetFileName(entry.FileName);
                if(filename.StartsWith("Firmware-")) {
                    string image_path = Path.Combine(firmware_export_path, filename);
                    archive.ExtractEntry(entry, image_path);
                    images.Add(image_path);
                }
            }

            File.Delete(cpio_out);
        }