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)); } }
public static void AddAPKFile(BackgroundWorker worker, string filename, string type) { Logger.WriteLog("Adding APK: " + Path.GetFileName(filename)); if (!Zipping.UnzipFile(worker, filename, "AndroidManifest.xml", string.Empty, Utility.GetTempPath(), false)) { Logger.WriteLog("Error adding APK: AndroidManifest.xml not found"); return; } string appname = Utility.ManifestGetName(File.ReadAllBytes(Path.Combine(Utility.GetTempPath(), "AndroidManifest.xml"))); File.Delete(Path.Combine(Utility.GetTempPath(), "AndroidManifest.xml")); if (appname == null) { Logger.WriteLog("Error adding APK: Could not read appname from AndroidManifest.xml"); return; } if (type == "App (System)") { Zipping.AddToZip(worker, Settings.destinationFile, filename, "system/app/" + appname + Path.GetExtension(filename), false); } else { Zipping.AddToZip(worker, Settings.destinationFile, filename, "data/app/" + appname + Path.GetExtension(filename), false); } }
public static void EditScript(BackgroundWorker worker, string search, string replace) { Zipping.UnzipFile(worker, Settings.destinationFile, "updater-script", "META-INF/com/google/android", Utility.GetTempPath(), false); string content = File.ReadAllText(Path.Combine(Utility.GetTempPath(), "updater-script"), Encoding.ASCII); content = content.Replace(search, replace); File.WriteAllText(Path.Combine(Utility.GetTempPath(), "updater-script"), content, Encoding.ASCII); Zipping.AddToZip(worker, Settings.destinationFile, Path.Combine(Utility.GetTempPath(), "updater-script"), "META-INF/com/google/android/updater-script", false); File.Delete(Path.Combine(Utility.GetTempPath(), "updater-script")); }
public static string ReadConfig(BackgroundWorker worker, string key) { Zipping.UnzipFile(worker, Settings.destinationFile, "prfconfig", string.Empty, Utility.GetTempPath(), false); string content = File.ReadAllText(Path.Combine(Utility.GetTempPath(), "prfconfig"), Encoding.ASCII); File.Delete(Path.Combine(Utility.GetTempPath(), "prfconfig")); if (!content.Contains(key + "=")) { return(null); } return(Regex.Match(content, "^" + key + "=(.*)$", RegexOptions.Multiline).Groups[1].Value); }
public static void EditConfig(BackgroundWorker worker, string key, string value) { Zipping.UnzipFile(worker, Settings.destinationFile, "prfconfig", string.Empty, Utility.GetTempPath(), false); string content = File.ReadAllText(Path.Combine(Utility.GetTempPath(), "prfconfig"), Encoding.ASCII); if (!content.Contains(key + "=")) { content += "\n" + key + "=" + value; } else { content = Regex.Replace(content, "^" + key + "=.*$", key + "=" + value, RegexOptions.Multiline); } File.WriteAllText(Path.Combine(Utility.GetTempPath(), "prfconfig"), content, Encoding.ASCII); Zipping.AddToZip(worker, Settings.destinationFile, Path.Combine(Utility.GetTempPath(), "prfconfig"), "prfconfig", false); File.Delete(Path.Combine(Utility.GetTempPath(), "prfconfig")); }
private static bool ExtractAndAddSin(BackgroundWorker worker, string name, string ftffile, string AsFilename = "") { if (Zipping.ExistsInZip(ftffile, name + ".sin") == false) { OnError(name, AsFilename); return(false); } Zipping.UnzipFile(worker, ftffile, name + ".sin", string.Empty, Utility.GetTempPath(), false); if (File.Exists(Path.Combine(Utility.GetTempPath(), name + ".sin"))) { Logger.WriteLog(" " + name); Zipping.AddToZip(worker, Settings.destinationFile, Path.Combine(Utility.GetTempPath(), name + ".sin"), (AsFilename == "" ? name : AsFilename) + ".sin", false, Ionic.Zlib.CompressionLevel.None); File.Delete(Path.Combine(Utility.GetTempPath(), name + ".sin")); } return(true); }
private static void UnpackSystem(BackgroundWorker worker) { SetJobNum(++JobNum); Logger.WriteLog("Extracting system.sin from " + System.IO.Path.GetFileName(Form1.form.ftf_textbox.Text)); if (!Zipping.UnzipFile(worker, Form1.form.ftf_textbox.Text, "system.sin", string.Empty, Utility.GetTempPath())) { worker.CancelAsync(); return; } byte[] UUID = PartitionInfo.ReadSinUUID(Path.Combine(Utility.GetTempPath(), "system.sin")); //PartitionInfo.ScriptMode = (UUID != null) ? PartitionInfo.Mode.LegacyUUID : PartitionInfo.Mode.Legacy; if (!Form1.form.options_checklist.CheckedItems.Contains("Legacy mode")) { PartitionInfo.ScriptMode = PartitionInfo.Mode.Sinflash; } else { PartitionInfo.ScriptMode = (UUID != null) ? PartitionInfo.Mode.LegacyUUID : PartitionInfo.Mode.Legacy; } Utility.ScriptSetUUID(worker, "system", UUID); }