private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { if (toc == null) { return; } SaveFileDialog d = new SaveFileDialog(); d.Filter = "*.toc|*.toc"; if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { rtb2.Text = "Start Compiling...\n"; if (!PrepareBJSON()) { return; } if (toc.iscas && !BuildSB(d.FileName)) { return; } if (!toc.iscas && !BuildSBBinary(d.FileName)) { return; } rtb2.AppendText("Writing " + Path.GetFileName(d.FileName) + " ...\n"); toc.Save(d.FileName); rtb2.AppendText("Saved " + Path.GetFileName(d.FileName) + "\n"); MessageBox.Show("Done"); } }
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog d = new SaveFileDialog(); d.Filter = "*.toc|*.toc"; if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { toc.Save(d.FileName); MessageBox.Show("Done."); } }
public void SaveFile(string path) { for (int i = 0; i < initfs.lines.Count; i++) { BJSON.Entry e = initfs.lines[i]; if (e.fields != null && e.fields.Count != 0) { BJSON.Field file = e.fields[0]; List <BJSON.Field> data = (List <BJSON.Field>)file.data; foreach (BJSON.Field f in data) { if (f.fieldname == "payload") { f.data = list[i].data; } } } initfs.lines[i] = e; } initfs.Save(path); RefreshList(); }
public static bool ExtractISO(string source, string target) { if (!File.Exists(source)) { return(false); } if (!Directory.Exists(target + "/&&systemdata")) { Directory.CreateDirectory(target + "/&&systemdata"); } long dolptr; long tocptr; long toclen; byte[] hdr = new byte[9280]; FileStream iso = new FileStream(source, FileMode.Open, FileAccess.Read); if (iso.Length < 9280) { return(false); } iso.Read(hdr, 0, 9280); dolptr = (hdr[1056] << 24) | (hdr[1057] << 16) | (hdr[1058] << 8) | hdr[1059]; tocptr = (hdr[1060] << 24) | (hdr[1061] << 16) | (hdr[1062] << 8) | hdr[1063]; toclen = (hdr[1064] << 24) | (hdr[1065] << 16) | (hdr[1066] << 8) | hdr[1067]; if (dolptr > iso.Length || tocptr > iso.Length || tocptr + toclen > iso.Length) { return(false); } using (FileStream hdrfile = new FileStream(target + "/&&systemdata/ISO.hdr", FileMode.Create, FileAccess.Write)) hdrfile.Write(hdr, 0, hdr.Length); using (FileStream apploader = new FileStream(target + "/&&systemdata/AppLoader.ldr", FileMode.Create, FileAccess.Write)) { byte[] buf = new byte[dolptr - 9280 - 92]; iso.Read(buf, 0, buf.Length); apploader.Write(buf, 0, buf.Length); } iso.Seek(dolptr, SeekOrigin.Begin); using (FileStream dol = new FileStream(target + "/&&systemdata/Start.dol", FileMode.Create, FileAccess.Write)) { byte[] buf = new byte[tocptr - dolptr]; iso.Read(buf, 0, buf.Length); dol.Write(buf, 0, buf.Length); } iso.Seek(tocptr, SeekOrigin.Begin); long filestart = iso.Position + toclen; TOCFile tocfile = new TOCFile(iso, (int)toclen); List <TOCFile.Entry> entries = tocfile.EnumerateEntries(); if (filestart % 4096 != 0) { filestart += 4096 - (filestart % 4096); } uint firstoffset = tocfile.FirstOffset; foreach (TOCFile.Entry entry in entries) { if (entry.children.Count > 0 && !Directory.Exists(target + "/" + entry.FullPath)) { Directory.CreateDirectory(target + "/" + entry.FullPath); } } foreach (TOCFile.Entry entry in entries) { if (entry.children.Count > 0) { continue; } using (FileStream fs = new FileStream(target + "/" + entry.FullPath, FileMode.Create, FileAccess.Write)) { byte[] buf = new byte[entry.length]; iso.Seek(entry.offset, SeekOrigin.Begin); iso.Read(buf, 0, buf.Length); fs.Write(buf, 0, buf.Length); } } iso.Close(); tocfile.Save(target + "/&&systemdata/Game.toc"); return(true); }