示例#1
0
        private void recompressToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog toOutput = new SaveFileDialog();

            toOutput.Title            = $"Save recompressed archive to where?";
            toOutput.Filter           = $"bin files|*.bin|All files (*.*)|*.*";
            toOutput.FilterIndex      = 0;
            toOutput.OverwritePrompt  = true;
            toOutput.RestoreDirectory = true;
            toOutput.FileName         = Path.GetFileName(archiveName.Replace(".raw", "")); //This won't be a raw file so we take that extension out
            DialogResult result = toOutput.ShowDialog();

            if (result == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                DateTime recompStart = DateTime.Now;
                AT7FileProcessor.recompressAT7P(new BinaryReader(File.Open(archiveName, FileMode.Open)), toOutput.FileName);
                Cursor = Cursors.Default;
                DateTime recompEnd = DateTime.Now;
                using (TextWriter datesLog = File.CreateText("dates.log")) //Just in case that end popup gets clicked through a little too fast
                {
                    datesLog.WriteLine("Start: " + recompStart.ToString());
                    datesLog.WriteLine("Finish " + recompEnd.ToString());
                }
                DialogResult recompressedTheFile = new DialogResult();
                recompressedTheFile = MessageBox.Show("Recompressed the file.\n" + "Start: " + recompStart.ToString() + "\nFinish: " + recompEnd.ToString());
            }
        }
示例#2
0
        private void loadThatFile()
        {
            fileCount = 0;
            treeView1.Nodes.Clear();
            BinaryReader quickie = new BinaryReader(File.Open(archiveName, FileMode.Open));

            fileThings = new byte[0x1C];

            fileThings = quickie.ReadBytes(0x1C);
            if (fileThings[0] == 0x41 && fileThings[1] == 0x54 && fileThings[2] == 0x37 && fileThings[3] == 0x50)
            {
                /*DialogResult pleaseWait = new DialogResult();
                 * pleaseWait = MessageBox.Show("Decompressing file...");*/
                //fileTypeDesc.Text = $"Compressed data opened. Decompressing to {Path.GetFileName(archiveName)}";
                AT7FileProcessor.decompressAT7P(quickie, archiveName);
                archiveName = archiveName.Insert(archiveName.Length, ".raw");
                DialogResult decompressedTheFile = new DialogResult();
                decompressedTheFile = MessageBox.Show($"Archive decompressed as {Path.GetFileName(archiveName)}. Be sure to open this one from now on and not the one you just opened.");
                //fileTypeDesc.ResetText();
            }
            quickie.Close();
            Console.WriteLine(archiveName);
            using (BinaryReader fileReader = new BinaryReader(File.Open(archiveName, FileMode.Open)))
            {
                Console.WriteLine(archiveName);
                //progressBarExtract.Maximum = (int)fileReader.BaseStream.Length;

                fileThings = new byte[0x1C];

                fileThings = fileReader.ReadBytes(0x1C);



                //fileDetailsNode = new List<uint>();
                while (!Enumerable.SequenceEqual(fileThings, namesEnd))
                {
                    Console.WriteLine(BitConverter.ToString(fileThings));

                    //Now to prepare the filename's real length to remove the junk text
                    fileNameLength = 0;
                    for (int i = 8; fileThings[i] != 0x00; i++)
                    {
                        fileNameLength++;
                    }
                    fileName = Encoding.UTF8.GetString(fileThings, 8, fileNameLength);
                    TreeNode toAdd = new TreeNode(fileName);

                    //Now let's nab that file extension
                    fileExtension = "???";
                    foreach (string thing in AT7FileTypes.fileTypes)
                    {
                        if (fileName.Contains(thing))
                        {
                            fileExtension = thing;
                        }
                    }


                    AT7FileNode currentNode = new AT7FileNode(ReverseBytes(BitConverter.ToUInt32(fileThings, 4)), ReverseBytes(BitConverter.ToUInt32(fileThings, 0)), fileName, fileExtension);

                    /*fileOffset = ReverseBytes(BitConverter.ToUInt32(fileThings, 0));
                     * fileSize = ReverseBytes(BitConverter.ToUInt32(fileThings, 4));
                     * fileDetailsNode.Add(fileOffset); fileDetailsNode.Add(fileSize);*/


                    toAdd.Tag                = currentNode;
                    toAdd.ImageIndex         = AT7FileTypes.fileTypes.IndexOf(fileExtension);
                    toAdd.SelectedImageIndex = AT7FileTypes.fileTypes.IndexOf(fileExtension);
                    treeView1.Nodes.Add(toAdd);

                    /*fileName = Encoding.UTF8.GetString(fileThings, 8, fileNameLength); //Aaaaaaaand filename applied
                     * //fileName = fileName.Substring(0, fileName.IndexOf("?"));
                     * //TreeNode fileNode new TreeNode();*/


                    Console.WriteLine(treeView1.Nodes[fileCount].Text);
                    fileCount++;
                    fileThings = fileReader.ReadBytes(0x1C); //While loop ends with this
                }
            }
        }