Esempio n. 1
0
        public static bool DumpISO(string isoFileName)
        {
            var    isoReader    = new ISOReader();
            string isoOutputDir = Path.Combine(rootDir, extractedISODir);

            if (!isoReader.OpenISOStream(isoFileName, isoOutputDir))
            {
                return(false); // ISOReader itself should take care of showing a detailed error message
            }

            DirectoryGuard.CheckDirectory(isoOutputDir);

            var isoFiles = isoReader.GetGenerator();

            foreach (var file in isoFiles)
            {
                string fileName = Path.Combine(isoOutputDir, file.name);

                DirectoryGuard.CheckDirectory(fileName);

                FileStream fs = new FileStream(fileName, FileMode.Create);

                file.dataStream.CopyTo(fs);

                fs.Close();
            }

            isoReader.CloseISOStream();

            return(true);
        }
Esempio n. 2
0
        private async Task PatchGameDeprecated()
        {
            ZipArchive patchDirectory = ZipFile.OpenRead(txtPatchPath.Text);

            var isoReader = new ISOReader();

            if (!isoReader.OpenISOStream(txtIsoPath.Text, txtOutputPath.Text))
            {
                return; // ISOReader itself should take care of showing a detailed error message
            }

            DirectoryGuard.CheckDirectory(txtOutputPath.Text);

            IEnumerable <ZipArchiveEntry> prebuiltFiles = patchDirectory.Entries.Where(patchEntry => patchEntry.Name.EndsWith(".cpk") || patchEntry.Name.EndsWith(".SFO"));

            var isoFiles = isoReader.GetGenerator();

            try
            {
                filesProcessed = 0;
                totalFiles     = (double)isoFiles.Count();

                //First We Dump the Iso and make list of files in need of patching.

                List <Task> tasks = isoFiles.Select(file => PatchFileDeprecated(file, prebuiltFiles)).ToList();

                await Task.WhenAll(tasks);

                MessageBox.Show("That was easy.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an issue. Please send the log located at " + logFilePath + " to Spud and yell at him to fix things.");
                using (System.IO.StreamWriter logFile = new System.IO.StreamWriter(logFilePath, true))
                {
                    logFile.WriteLine("Exception hit:\n" + ex.ToString());
                }
            }
            finally
            {
                isoReader.CloseISOStream();

                //Re-Enable text boxes
                txtIsoPath.Enabled    = true;
                btnIsoPath.Enabled    = true;
                txtPatchPath.Enabled  = true;
                btnPatchPath.Enabled  = true;
                txtOutputPath.Enabled = true;
                btnOutputPath.Enabled = true;

                System.Timers.Timer renablePatchTier = new System.Timers.Timer(2000);
                renablePatchTier.Elapsed  += ReenablePatchButton;
                renablePatchTier.AutoReset = false;
                renablePatchTier.Enabled   = true;
            }
        }