Example #1
0
        private static void ExtractAndAdd(BackgroundWorker worker, string name, string extension, string ftffile, string AsFilename = "")
        {
            if (Zipping.ExistsInZip(ftffile, name + ".sin") == false)
            {
                OnError(name, AsFilename);
                return;
            }

            Zipping.UnzipFile(worker, ftffile, name + ".sin", string.Empty, Utility.GetTempPath(), false);
            if (File.Exists(Path.Combine(Utility.GetTempPath(), name + ".sin")))
            {
                Logger.WriteLog("   " + name);
                SinExtract.ExtractSin(worker, Path.Combine(Utility.GetTempPath(), name + ".sin"), Path.Combine(Utility.GetTempPath(), name + extension), false);

                if (PartitionInfo.ScriptMode == PartitionInfo.Mode.LegacyUUID)
                {
                    byte[] UUID = PartitionInfo.ReadSinUUID(Path.Combine(Utility.GetTempPath(), name + ".sin"));
                    Utility.ScriptSetUUID(worker, (AsFilename == "" ? name : AsFilename), UUID);
                }

                File.Delete(Path.Combine(Utility.GetTempPath(), name + ".sin"));
                Zipping.AddToZip(worker, Settings.destinationFile, Path.Combine(Utility.GetTempPath(), name + extension), (AsFilename == "" ? name : AsFilename) + extension, false);
                File.Delete(Path.Combine(Utility.GetTempPath(), name + extension));
            }
        }
Example #2
0
        public static void ExtractSin(BackgroundWorker sender, string sinfile, string outfile, bool log = true)
        {
            using (FileStream stream = new FileStream(sinfile, FileMode.Open, FileAccess.Read))
                using (BinaryReader br = new BinaryReader(stream))
                {
                    if (log)
                    {
                        Logger.WriteLog("Verifying extracted Sin File");
                    }
                    ;
                    if (!SinFile.VerifySin(br))
                    {
                        sender.CancelAsync();
                        return;
                    }

                    List <SinFile.BlockInfoHeader> bihs = null;
                    int SinVer = SinFile.GetSinVersion(br);
                    switch (SinVer)
                    {
                    case 2:
                        bihs = SinFileV2.GetBIHs(br);
                        break;

                    case 3:
                        bihs = SinFileV3.GetBIHs(br);
                        break;
                    }
                    if (log)
                    {
                        Logger.WriteLog("Extracting image from Sin File " + Path.GetFileName(sinfile));
                    }

                    SinExtract.ExtractSinData(sender, br, bihs, outfile, log);
                }
        }
Example #3
0
 private static void UnpackSystemEXT4(BackgroundWorker worker)
 {
     SetJobNum(++JobNum);
     SinExtract.ExtractSin(worker, Path.Combine(Utility.GetTempPath(), "system.sin"), Path.Combine(Utility.GetTempPath(), "system.ext4"));
     File.Delete(Path.Combine(Utility.GetTempPath(), "system.sin"));
 }