Esempio n. 1
0
        internal static void ReplaceFileInIso(IsoFileInfo fileToReplace, string pathToNewFile)
        {
            var newFile = new FileStream(pathToNewFile, System.IO.FileMode.Open, System.IO.FileAccess.Read);

            byte[] newFileData = new byte[newFile.Length];
            newFile.Read(newFileData, 0, (int)newFile.Length);
            newFile.Close();
            ReplaceFileInIso(fileToReplace, newFileData);
        }
Esempio n. 2
0
 internal static byte[] OpenDatFile(IsoFileInfo info)
 {
     byte[] outFile = new byte[info.Size];
     _streamFile.Seek(info.FileOffset, SeekOrigin.Begin);
     for (int i = 0; i < info.Size; i++)
     {
         outFile[i] = (byte)_streamFile.ReadByte();
     }
     return(outFile);
 }
Esempio n. 3
0
 internal static void ReplaceFileInIso(IsoFileInfo fileToReplace, byte[] newFileData)
 {
     if (fileToReplace.Size != newFileData.Length)
     {
         MessageBox.Show("Error: New file is not the same size!");
         return;
     }
     _streamFile.Seek(fileToReplace.FileOffset, SeekOrigin.Begin);
     _streamFile.Write(newFileData, 0, newFileData.Length);
     MessageBox.Show("File replacement has completed successfully!");
 }
Esempio n. 4
0
        internal static void ExportFileFromIso(IsoFileInfo info, SaveFileDialog dialog)
        {
            Stream myStream;

            if ((myStream = dialog.OpenFile()) != null)
            {
                var fileToSave = new byte[info.Size];
                _streamFile.Seek(info.FileOffset, SeekOrigin.Begin);
                _streamFile.Read(fileToSave, 0, (int)info.Size);
                myStream.Write(fileToSave, 0, (int)info.Size);
                myStream.Close();
            }
        }
Esempio n. 5
0
        private void button4_Click(object sender, EventArgs e)
        {
            string      datFileName = DatFile.fileName;
            IsoFileInfo fileInfo    = IsoFile.SearchIso(datFileName, filesystemTreeView.Nodes[0]);

            if (fileInfo == null)
            {
                MessageBox.Show("Error finding file in disc image!");
            }
            else
            {
                IsoFile.ReplaceFileInIso(fileInfo, DatFile.file);
            }
        }
Esempio n. 6
0
        private void Button_Export_Click(object sender, EventArgs e)
        {
            IsoFileInfo info            = (IsoFileInfo)filesystemTreeView.SelectedNode.Tag;
            String      extension       = info.Name.Substring(info.Name.IndexOf('.'));
            var         saveFileDialog1 = new SaveFileDialog
            {
                Title            = "Export File",
                InitialDirectory = Settings.Default.saveDatFilePath,
                FileName         = info.Name,
                Filter           = "All files|*.*",
                FilterIndex      = 1,
                AddExtension     = true
            };

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.saveDatFilePath = Path.GetDirectoryName(saveFileDialog1.FileName);
                IsoFile.ExportFileFromIso(info, saveFileDialog1);
            }
        }
Esempio n. 7
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (filesystemTreeView.SelectedNode == null || filesystemTreeView.SelectedNode.Nodes.Count > 0)
            {
                Button_Export.Enabled = false;
                Button_Open.Enabled   = false;
                button6.Enabled       = false;
            }

            else
            {
                Button_Export.Enabled = filesystemTreeView.SelectedNode.Text.IndexOf(".") != -1;
                Button_Open.Enabled   = filesystemTreeView.SelectedNode.Text.IndexOf(".") != -1;
                button6.Enabled       = filesystemTreeView.SelectedNode.Text.IndexOf(".") != -1;
            }

            IsoFileInfo fileInfo = (IsoFileInfo)filesystemTreeView.SelectedNode.Tag;

            label5.Text = fileInfo.Name;
            label4.Text = fileInfo.Size.ToString() + " bytes";
        }
Esempio n. 8
0
        internal static void BuildNodes(TreeNode root, uint endOffset)
        {
            IsoFileInfo rootInfo      = (IsoFileInfo)root.Tag;
            uint        currentOffset = rootInfo.FSTOffset + 0xC;

            while (currentOffset < endOffset)
            {
                _streamFile.Seek(currentOffset, SeekOrigin.Begin);
                bool isNewNodeFolder = _streamFile.ReadByte() == 1;

                var buffer = new byte[4];
                _streamFile.Read(buffer, 1, 3);
                buffer[0] = 0;
                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(buffer);
                }
                uint   newNodeStringOffset = BitConverter.ToUInt32(buffer, 0);
                string newNodeName         = GetFilename(newNodeStringOffset);

                _streamFile.Read(buffer, 0, 4);
                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(buffer);
                }
                uint newNodeFileOffset = BitConverter.ToUInt32(buffer, 0);  //If a folder, this is offset to parent

                _streamFile.Read(buffer, 0, 4);
                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(buffer);
                }
                uint newNodeFileSize = BitConverter.ToUInt32(buffer, 0);    //If a folder, this is the # of files (from FST start) to the next non-child entry

                var newNode = new TreeNode(newNodeName);

                newNode.Tag = new IsoFileInfo(newNodeName, newNodeFileSize, newNodeFileOffset, currentOffset, isNewNodeFolder);
                string fileType = newNodeName.Substring(0, 2);
                switch (fileType)
                {
                case "Pl":
                    newNode.ImageIndex         = 1;
                    newNode.SelectedImageIndex = 1;
                    break;

                case "Gr":
                    newNode.ImageIndex         = 2;
                    newNode.SelectedImageIndex = 2;
                    break;

                default:
                    if (isNewNodeFolder)
                    {
                        newNode.ImageIndex         = 3;
                        newNode.SelectedImageIndex = 3;
                    }
                    break;
                }

                root.Nodes.Add(newNode);
                currentOffset += 0xC;

                if (isNewNodeFolder)
                {
                    currentOffset = FSTOffset + (newNodeFileSize * 0xC);
                    BuildNodes(newNode, currentOffset);
                }
            }
        }
Esempio n. 9
0
        private void Button_Open_Click(object sender, EventArgs e)
        {
            IsoFileInfo info = (IsoFileInfo)filesystemTreeView.SelectedNode.Tag;

            OpenDatFileAndUpdateWindow(IsoFile.OpenDatFile(info), info.Name);
        }
Esempio n. 10
0
 internal static void ReplaceFileInIso(IsoFileInfo fileToReplace, string pathToNewFile)
 {
     var newFile = new FileStream(pathToNewFile, System.IO.FileMode.Open, System.IO.FileAccess.Read);
     byte[] newFileData = new byte[newFile.Length];
     newFile.Read(newFileData, 0, (int)newFile.Length);
     newFile.Close();
     ReplaceFileInIso(fileToReplace, newFileData);
 }
Esempio n. 11
0
        internal static void ReplaceFileInIso(IsoFileInfo fileToReplace, byte[] newFileData)
        {
            if (fileToReplace.Size != newFileData.Length)
            {
                MessageBox.Show("Error: New file is not the same size!");
                return;
            }
            _streamFile.Seek(fileToReplace.FileOffset, SeekOrigin.Begin);
            _streamFile.Write(newFileData, 0, newFileData.Length);
            MessageBox.Show("File replacement has completed successfully!");

        }
Esempio n. 12
0
 internal static byte[] OpenDatFile(IsoFileInfo info)
 {
     byte[] outFile = new byte[info.Size];
     _streamFile.Seek(info.FileOffset, SeekOrigin.Begin);
     for (int i = 0; i < info.Size; i++)
     {
         outFile[i] = (byte) _streamFile.ReadByte();
     }
     return outFile;
 }
Esempio n. 13
0
 internal static void ExportFileFromIso(IsoFileInfo info, SaveFileDialog dialog)
 {
     Stream myStream;
     if ((myStream = dialog.OpenFile()) != null)
     {
         var fileToSave = new byte[info.Size];
         _streamFile.Seek(info.FileOffset, SeekOrigin.Begin);
         _streamFile.Read(fileToSave, 0, (int) info.Size);
         myStream.Write(fileToSave, 0, (int) info.Size);
         myStream.Close();
         
     }
 }