示例#1
0
 private void openFile(string file)
 {
     treeView1.Nodes.Clear();
     filename = file;
     Text     = file;
     if (Path.GetExtension(file).Equals(".szs"))
     {
         byte[] szs = YAZ0.Decompress(File.ReadAllBytes(file));
         Console.WriteLine("YAZ0 decompressed");
         if ((new FileData(szs)).readString(0, 4).Equals("SARC"))
         {
             SARC sarc = new SARC();
             sarc.Read(szs);
             globalPadding = sarc.padding;
             bigEndianToolStripMenuItem.Checked = (sarc.endian == Endianness.Big);
             foreach (string name in sarc.files.Keys)
             {
                 treeView1.Nodes.Add(new TreeNode(name)
                 {
                     Tag = sarc.files[name]
                 });
             }
         }
         else
         {
             treeView1.Nodes.Add(new TreeNode("contents.bin")
             {
                 Tag = szs
             });
         }
     }
     else
     {
         SARC sarc = new SARC(file);
         globalPadding = sarc.padding;
         bigEndianToolStripMenuItem.Checked = (sarc.endian == Endianness.Big);
         foreach (string name in sarc.files.Keys)
         {
             treeView1.Nodes.Add(new TreeNode(name)
             {
                 Tag = sarc.files[name]
             });
         }
     }
 }
示例#2
0
 protected void openFile(string fileName)
 {
     nodeStore.Clear();
     if (String.IsNullOrEmpty(fileName))
     {
         //extractAllAction.Activated = false;
         return;
     }
     if (System.IO.Path.GetExtension(fileName).Equals(".szs") ||
         System.IO.Path.GetExtension(fileName).Equals(".carc"))
     {
         byte[] szs = YAZ0.Decompress(File.ReadAllBytes(fileName));
         Console.WriteLine("YAZ0 decompressed");
         if ((new FileData(szs)).readString(0, 4).Equals("SARC"))
         {
             SARC sarc = new SARC();
             sarc.Read(szs);
             //globalPadding = sarc.padding;
             endianToggle.Active = (sarc.endian == Endianness.Big);
             foreach (string name in sarc.files.Keys)
             {
                 nodeStore.AddNode(new TreeNode(name, sarc.files[name]));
                 //treeView1.Nodes.Add(new TreeNode(name) { Tag = sarc.files[name] });
             }
         }
         else
         {
             nodeStore.AddNode(new TreeNode("contents.bin", szs));
             //treeView1.Nodes.Add(new TreeNode("contents.bin") { Tag = szs });
         }
     }
     else
     {
         SARC sarc = new SARC(fileName);
         //globalPadding = sarc.padding;
         endianToggle.Active = (sarc.endian == Endianness.Big);
         foreach (string name in sarc.files.Keys)
         {
             nodeStore.AddNode(new TreeNode(name, sarc.files[name]));
             //treeView1.Nodes.Add(new TreeNode(name) { Tag = sarc.files[name] });
         }
     }
 }
示例#3
0
        private void paddedYAZ0SARCszsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Settings s = new Settings();

            s.bigEndian = bigEndianToolStripMenuItem.Checked;
            (new exportSettings(s)).ShowDialog();
            if (!s.save)
            {
                return;
            }
            using (var sfd = new SaveFileDialog())
            {
                sfd.Filter = "All supported Filetypes (.szs, .sarc, .arc, .pack, .bars, .bgenv)|*.szs;*.sarc;*.arc;*.pack;*.bars;*.bgenv|" +
                             "YAZ0 compressed File (.szs)|*.szs|" +
                             "SARC archive (.sarc, .arc, .pack, .bars, .bgenv)|*.sarc;*.arc;*.pack;*.bars;*.bgenv|" +
                             "All Files|*.*";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SARC sarc = new SARC();
                    sarc.padding = s.offset;
                    if (!s.bigEndian)
                    {
                        sarc.endian = Endianness.Little;
                    }
                    foreach (TreeNode t in treeView1.Nodes)
                    {
                        sarc.files.Add(t.Text, (byte[])t.Tag);
                    }
                    if (Path.GetExtension(sfd.FileName) == ".szs")
                    {
                        File.WriteAllBytes(sfd.FileName, YAZ0.LazyCompress(sarc.Rebuild(), s.flags));
                    }
                    else
                    {
                        File.WriteAllBytes(sfd.FileName, sarc.Rebuild());
                    }
                }
            }
        }
示例#4
0
        private void yAZ0FileszsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeView1.Nodes.Count > 0)
            {
                using (var sfd = new SaveFileDialog())
                {
                    sfd.Filter = "YAZ0 Compressed SARC (.szs)|*.szs";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        if (treeView1.SelectedNode != null)
                        {
                            File.WriteAllBytes(sfd.FileName, YAZ0.LazyCompress((byte[])treeView1.SelectedNode.Tag));
                        }
                        else
                        {
                            File.WriteAllBytes(sfd.FileName, YAZ0.LazyCompress((byte[])treeView1.Nodes[0].Tag));
                        }
                    }
                }
            }
        }
示例#5
0
        private void yAZ0SARCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var sfd = new SaveFileDialog())
            {
                sfd.Filter = "YAZ0 Compressed SARC (.szs)|*.szs";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SARC sarc = new SARC();
                    sarc.padding = globalPadding;
                    if (!bigEndianToolStripMenuItem.Checked)
                    {
                        sarc.endian = Endianness.Little;
                    }
                    foreach (TreeNode t in treeView1.Nodes)
                    {
                        sarc.files.Add(t.Text, (byte[])t.Tag);
                    }
                    File.WriteAllBytes(sfd.FileName, YAZ0.LazyCompress(sarc.Rebuild()));
                }
            }
        }