Ejemplo n.º 1
0
        private void doCleanup(Psf2ToPsf2LibStruct pPsf2ToPsf2LibStruct)
        {
            try
            {
                // remove mkpsf2
                File.Delete(Path.Combine(PSF2_WORKING_FOLDER, Path.GetFileName(MKPSF2_SOURCE_PATH)));

                // copy files to rip folder
                string destinationFolder =
                    Path.Combine(PSF2_RIPS_FOLDER, Path.GetFileNameWithoutExtension(pPsf2ToPsf2LibStruct.libraryName));

                if (!Directory.Exists(destinationFolder))
                {
                    Directory.CreateDirectory(destinationFolder);
                }

                foreach (string f in Directory.GetFiles(PSF2_WORKING_FOLDER))
                {
                    File.Move(f, Path.Combine(destinationFolder, Path.GetFileName(f)));
                }

                // delete working folders
                Directory.Delete(PSF2_WORKING_FOLDER, true);
                Directory.Delete(PSF2LIB_WORKING_FOLDER, true);
            }
            catch (Exception ex)
            {
                int progress = (fileCount * 100) / maxFiles;
                this.progressStruct              = new VGMToolbox.util.ProgressStruct();
                this.progressStruct.NewNode      = null;
                this.progressStruct.ErrorMessage = "Error cleaning up.  Error received: " + ex.Message;
                ReportProgress(progress, this.progressStruct);
            }
        }
Ejemplo n.º 2
0
        public ExternalListFileRenamerWorker()
        {
            this.progressStruct = new VGMToolbox.util.ProgressStruct();

            WorkerReportsProgress      = true;
            WorkerSupportsCancellation = true;
        }
Ejemplo n.º 3
0
        public Mk2sfWorker()
        {
            this.progressStruct = new VGMToolbox.util.ProgressStruct();

            WorkerReportsProgress      = true;
            WorkerSupportsCancellation = true;
        }
Ejemplo n.º 4
0
        protected virtual void backgroundWorker_ReportProgress(object sender, ProgressChangedEventArgs e)
        {
            VGMToolbox.util.ProgressStruct vProgressStruct = (VGMToolbox.util.ProgressStruct)e.UserState;

            if (e.ProgressPercentage != Constants.IgnoreProgress &&
                e.ProgressPercentage != Constants.ProgressMessageOnly)
            {
                this.toolStripProgressBar.Value = e.ProgressPercentage;
                this.Text = "VGMToolbox [" + e.ProgressPercentage + "%]";

                if (!String.IsNullOrEmpty(vProgressStruct.GenericMessage))
                {
                    this.tbOutput.Text += vProgressStruct.GenericMessage;
                }
            }

            if ((e.ProgressPercentage == Constants.ProgressMessageOnly) && e.UserState != null)
            {
                tbOutput.Text += vProgressStruct.GenericMessage;
            }
            else if (e.UserState != null)
            {
                lblProgressLabel.Text = vProgressStruct.FileName ?? String.Empty;

                if (!String.IsNullOrEmpty(vProgressStruct.ErrorMessage))
                {
                    tbOutput.Text += vProgressStruct.ErrorMessage;
                    errorFound     = true;
                }
            }

            this.showElapsedTime();
        }
Ejemplo n.º 5
0
        private void checkForDupes(AuditingUtil pAuditingUtil, StreamWriter pStreamwriter)
        {
            ArrayList keys = new ArrayList(pAuditingUtil.ChecksumHash.Keys);
            int       progress;

            this.progressStruct = new VGMToolbox.util.ProgressStruct();

            foreach (string k in keys)
            {
                progress = (++totalItems * 100) / maxItems;
                this.progressStruct.FileName = k;
                ReportProgress(progress, this.progressStruct);

                ArrayList gameList = (ArrayList)pAuditingUtil.ChecksumHash[k];
                if (gameList.Count > 1)
                {
                    pStreamwriter.Write(String.Format("Checksum: {0}", k) + Environment.NewLine);

                    foreach (AuditingUtil.ChecksumStruct cs in gameList)
                    {
                        pStreamwriter.Write(AuditingUtil.ROM_SPACER + cs.game +
                                            Path.DirectorySeparatorChar + cs.rom + Environment.NewLine);
                    }
                    pStreamwriter.Write(Environment.NewLine);
                }
            }
        }
Ejemplo n.º 6
0
        private string[] getUniqueFileNames(string pSourceDirectory)
        {
            int fileCount = 0;
            int i         = 0;

            string[] ret = null;

            VGMToolbox.util.ProgressStruct vProgressStruct = new VGMToolbox.util.ProgressStruct();

            if (!Directory.Exists(pSourceDirectory))
            {
                vProgressStruct              = new VGMToolbox.util.ProgressStruct();
                vProgressStruct.NewNode      = null;
                vProgressStruct.ErrorMessage = String.Format("ERROR: Directory {0} not found.", pSourceDirectory);
                ReportProgress(Constants.ProgressMessageOnly, vProgressStruct);
            }
            else
            {
                fileCount = Directory.GetFiles(pSourceDirectory, "*.SQ").Length;

                if (fileCount > 0)
                {
                    ret = new string[fileCount];
                }

                foreach (string f in Directory.GetFiles(pSourceDirectory, "*.SQ"))
                {
                    ret[i] = f;
                    i++;
                }
            }

            return(ret);
        }
Ejemplo n.º 7
0
        private void executeBatchScript()
        {
            Process psfProcess;

            try
            {
                // copy psfpoint.exe
                string psfpointDestinationPath = Path.Combine(PSF2_WORKING_FOLDER, Path.GetFileName(PSFPOINT_SOURCE_PATH));
                File.Copy(PSFPOINT_SOURCE_PATH, psfpointDestinationPath, true);

                // execute script
                psfProcess           = new Process();
                psfProcess.StartInfo = new ProcessStartInfo(Path.Combine(PSF2_WORKING_FOLDER, PSFPOINT_BATCH_FILE));
                psfProcess.StartInfo.UseShellExecute  = false;
                psfProcess.StartInfo.WorkingDirectory = PSF2_WORKING_FOLDER;
                psfProcess.StartInfo.CreateNoWindow   = true;
                psfProcess.Start();
                psfProcess.WaitForExit();
                psfProcess.Close();
                psfProcess.Dispose();

                // delete file
                File.Delete(psfpointDestinationPath);
            }
            catch (Exception ex)
            {
                int progress = (fileCount * 100) / maxFiles;
                this.progressStruct              = new VGMToolbox.util.ProgressStruct();
                this.progressStruct.NewNode      = null;
                this.progressStruct.ErrorMessage =
                    "Error executing batch script.  Error received: " + ex.Message +
                    Environment.NewLine;
                ReportProgress(progress, this.progressStruct);
            }
        }
Ejemplo n.º 8
0
        public DatafileCreatorWorker()
        {
            fileCount      = 0;
            progressStruct = new VGMToolbox.util.ProgressStruct();

            WorkerReportsProgress      = true;
            WorkerSupportsCancellation = true;
        }
Ejemplo n.º 9
0
        public Xsf2sfTagMigratorWorker()
        {
            this.progressStruct             = new VGMToolbox.util.ProgressStruct();
            this.WorkerReportsProgress      = true;
            this.WorkerSupportsCancellation = true;

            this.progress = 0;
        }
Ejemplo n.º 10
0
        public SsfMakeWorker()
        {
            fileCount           = 0;
            maxFiles            = 0;
            this.progressStruct = new VGMToolbox.util.ProgressStruct();

            WorkerReportsProgress      = true;
            WorkerSupportsCancellation = true;
        }
Ejemplo n.º 11
0
        public TreeBuilderWorker()
        {
            fileCount      = 0;
            maxFiles       = 0;
            progressStruct = new VGMToolbox.util.ProgressStruct();

            WorkerReportsProgress      = true;
            WorkerSupportsCancellation = true;
        }
Ejemplo n.º 12
0
        protected AVgmtDragAndDropWorker()
        {
            this.progressCounter            = 0;
            this.progressCounterIncrementer = AVgmtDragAndDropWorker.DefaultProgressCounterIncrementValue;
            this.outputBuffer = new StringBuilder();

            this.progressStruct             = new VGMToolbox.util.ProgressStruct();
            this.WorkerReportsProgress      = true;
            this.WorkerSupportsCancellation = true;
        }
Ejemplo n.º 13
0
        private bool unpackPsf2File(string pSourcePath, string pOutputPath)
        {
            int     progress;
            bool    isSuccess       = false;
            Process unpkPsf2Process = null;

            try
            {
                // create dir
                if (!Directory.Exists(pOutputPath))
                {
                    Directory.CreateDirectory(pOutputPath);
                }

                // call unpkpsf2.exe
                string arguments = String.Format(" \"{0}\" \"{1}\"", pSourcePath, pOutputPath);
                unpkPsf2Process           = new Process();
                unpkPsf2Process.StartInfo = new ProcessStartInfo(UNPKPSF2_SOURCE_PATH, arguments);
                unpkPsf2Process.StartInfo.UseShellExecute = false;
                unpkPsf2Process.StartInfo.CreateNoWindow  = true;
                isSuccess = unpkPsf2Process.Start();
                unpkPsf2Process.WaitForExit();
                unpkPsf2Process.Close();
                unpkPsf2Process.Dispose();
            }
            catch (Exception ex)
            {
                isSuccess = false;

                if ((unpkPsf2Process != null) && (!unpkPsf2Process.HasExited))
                {
                    unpkPsf2Process.Close();
                    unpkPsf2Process.Dispose();
                }

                progress                         = (fileCount * 100) / maxFiles;
                this.progressStruct              = new VGMToolbox.util.ProgressStruct();
                this.progressStruct.NewNode      = null;
                this.progressStruct.ErrorMessage = String.Format("Error processing <{0}>.  Error received: ", pSourcePath) + ex.Message;
                ReportProgress(progress, this.progressStruct);
            }

            return(isSuccess);
        }
Ejemplo n.º 14
0
        protected override void backgroundWorker_ReportProgress(object sender, ProgressChangedEventArgs e)
        {
            if (e.ProgressPercentage != Constants.IgnoreProgress &&
                e.ProgressPercentage != Constants.ProgressMessageOnly)
            {
                toolStripProgressBar.Value = e.ProgressPercentage;
            }

            if ((e.ProgressPercentage == Constants.ProgressMessageOnly) && e.UserState != null)
            {
                VGMToolbox.util.ProgressStruct vProgressStruct = (VGMToolbox.util.ProgressStruct)e.UserState;
                tbOutput.Text += vProgressStruct.GenericMessage;
            }
            else if (e.UserState != null)
            {
                VGMToolbox.util.ProgressStruct vProgressStruct = (VGMToolbox.util.ProgressStruct)e.UserState;

                if (vProgressStruct.NewNode != null)
                {
                    treeViewTools.Nodes.Add(vProgressStruct.NewNode);

                    if (this.outputToText)
                    {
                        using (StreamWriter sw =
                                   new StreamWriter(File.Open(this.outputTextFile, FileMode.Append, FileAccess.Write), System.Text.Encoding.Unicode))
                        {
                            this.writeNodesToFile(vProgressStruct.NewNode, sw, 0);
                        }
                    }
                }

                lblProgressLabel.Text = vProgressStruct.FileName ?? String.Empty;

                if (!String.IsNullOrEmpty(vProgressStruct.ErrorMessage))
                {
                    tbOutput.Text += vProgressStruct.ErrorMessage;
                    errorFound     = true;
                }
            }

            this.showElapsedTime();
        }
Ejemplo n.º 15
0
        private void backgroundWorker_ReportProgress(object sender, ProgressChangedEventArgs e)
        {
            if (e.ProgressPercentage != Constants.IgnoreProgress &&
                e.ProgressPercentage != Constants.ProgressMessageOnly)
            {
                toolStripProgressBar.Value = e.ProgressPercentage;
                this.Text = "mkpsf2FE [" + e.ProgressPercentage + "%]";
            }

            if ((e.ProgressPercentage == Constants.ProgressMessageOnly) && e.UserState != null)
            {
                VGMToolbox.util.ProgressStruct vProgressStruct = (VGMToolbox.util.ProgressStruct)e.UserState;
                tbOutput.Text += vProgressStruct.GenericMessage;
            }
            else if (e.UserState != null)
            {
                VGMToolbox.util.ProgressStruct vProgressStruct = (VGMToolbox.util.ProgressStruct)e.UserState;
                tbOutput.Text += vProgressStruct.ErrorMessage ?? String.Empty;
            }
        }
Ejemplo n.º 16
0
        private bool addTagsToTagScript(string pFileName,
                                        Dictionary <string, string> pTagHash, string pLibName)
        {
            bool   isSuccess     = true;
            string batchFilePath = Path.Combine(PSF2_WORKING_FOLDER, PSFPOINT_BATCH_FILE);

            try
            {
                using (StreamWriter sw = new StreamWriter(File.Open(batchFilePath, FileMode.Append, FileAccess.Write)))
                {
                    foreach (string k in pTagHash.Keys)
                    {
                        sw.WriteLine("psfpoint.exe -{0}=\"{1}\" \"{2}\"",
                                     k, pTagHash[k], Path.GetFileNameWithoutExtension(pFileName) + ".minipsf2");
                    }

                    // add lib
                    sw.WriteLine("psfpoint.exe -{0}=\"{1}\" \"{2}\"",
                                 "_lib", pLibName, Path.GetFileNameWithoutExtension(pFileName) + ".minipsf2");
                    sw.WriteLine();

                    sw.Close();
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;

                int progress = (fileCount * 100) / maxFiles;
                this.progressStruct              = new VGMToolbox.util.ProgressStruct();
                this.progressStruct.NewNode      = null;
                this.progressStruct.ErrorMessage = String.Format("Error adding batch file info for <{0}>.  Error received: ", pFileName) + ex.Message;
                ReportProgress(progress, this.progressStruct);
            }

            return(isSuccess);
        }
Ejemplo n.º 17
0
        private void buildPsf2Lib(Psf2ToPsf2LibStruct pPsf2ToPsf2LibStruct, DoWorkEventArgs e)
        {
            bool isSuccess;

            if (!Directory.Exists(pPsf2ToPsf2LibStruct.sourcePath))
            {
                this.progressStruct              = new VGMToolbox.util.ProgressStruct();
                this.progressStruct.NewNode      = null;
                this.progressStruct.FileName     = null;
                this.progressStruct.ErrorMessage =
                    String.Format("ERROR: Directory <{0}> Not Found.", pPsf2ToPsf2LibStruct.sourcePath);
                ReportProgress(0, this.progressStruct);
            }
            else
            {
                // Get Max Files
                this.maxFiles = Directory.GetFiles(pPsf2ToPsf2LibStruct.sourcePath, "*.psf2").Length;

                pPsf2ToPsf2LibStruct.libraryName =
                    FileUtil.CleanFileName(pPsf2ToPsf2LibStruct.libraryName) +
                    ".psf2lib";

                foreach (string f in
                         Directory.GetFiles(pPsf2ToPsf2LibStruct.sourcePath, "*.psf2"))
                {
                    // report progress
                    int progress = (++this.fileCount * 100) / maxFiles;
                    this.progressStruct          = new VGMToolbox.util.ProgressStruct();
                    this.progressStruct.NewNode  = null;
                    this.progressStruct.FileName = f;
                    ReportProgress(progress, this.progressStruct);

                    using (FileStream fs = File.OpenRead(f))
                    {
                        // check type
                        Type dataType = FormatUtil.getObjectType(fs);

                        if (dataType != null && dataType.Name.Equals("Xsf"))
                        {
                            Xsf psf2File = new Xsf();
                            psf2File.Initialize(fs, f);

                            if (psf2File.GetFormat().Equals(Xsf.FormatNamePsf2))
                            {
                                // copy tags
                                Dictionary <string, string> tagHash = psf2File.GetTagHash();

                                // unpack files
                                string outputDir = Path.Combine(PSF2_WORKING_FOLDER,
                                                                Path.GetFileNameWithoutExtension(f));
                                isSuccess = this.unpackPsf2File(f, outputDir);

                                if (isSuccess)
                                {
                                    // move non.ini files to lib working dir
                                    isSuccess = moveNonIniFiles(outputDir, PSF2LIB_WORKING_SUBFOLDER);

                                    // make simple psf2 with just pointer .ini
                                    isSuccess = makeMiniPsf2(outputDir);

                                    if (isSuccess)
                                    {
                                        // update tag script
                                        addTagsToTagScript(f, tagHash, pPsf2ToPsf2LibStruct.libraryName);
                                    }
                                }
                            } // if (psf2File.getFormat().Equals(Xsf.FORMAT_NAME_PSF2))
                        }     // if (dataType != null && dataType.Name.Equals("Xsf"))

                        fs.Close();
                    } // using (FileStream fs = File.OpenRead(f))
                }     // foreach (string f in Directory.GetFiles(pPsf2ToPsf2LibStruct.sourcePath, "*.psf2"))

                // combine files into lib
                makePsf2Lib(PSF2LIB_WORKING_SUBFOLDER, pPsf2ToPsf2LibStruct.libraryName);

                // execute tagging script
                executeBatchScript();

                // move completed psf2s to rip folder
                doCleanup(pPsf2ToPsf2LibStruct);
            }
        }
Ejemplo n.º 18
0
 public RebuilderWorker()
 {
     progressStruct             = new VGMToolbox.util.ProgressStruct();
     WorkerReportsProgress      = true;
     WorkerSupportsCancellation = true;
 }
Ejemplo n.º 19
0
        private void buildPsf2s(string[] pUniqueSqFiles, MkPsf2Struct pMkPsf2Struct,
                                DoWorkEventArgs e)
        {
            Process makePsf2Process;

            VGMToolbox.util.ProgressStruct vProgressStruct = new VGMToolbox.util.ProgressStruct();

            string makePsf2SourcePath      = Path.Combine(PROGRAMS_FOLDER, "mkpsf2.exe");
            string makePsf2DestinationPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "mkpsf2.exe");

            try
            {
                Directory.CreateDirectory(WORKING_FOLDER);

                // copy generic modules to working directory
                File.Copy(Path.Combine(MODULES_FOLDER, "psf2.irx"), Path.Combine(WORKING_FOLDER, "psf2.irx"), true);
                File.Copy(Path.Combine(MODULES_FOLDER, "sq.irx"), Path.Combine(WORKING_FOLDER, "sq.irx"), true);

                // copy source modules to working directory
                File.Copy(Path.Combine(pMkPsf2Struct.modulePath, "LIBSD.IRX"), Path.Combine(WORKING_FOLDER, "LIBSD.IRX"), true);
                File.Copy(Path.Combine(pMkPsf2Struct.modulePath, "MODHSYN.IRX"), Path.Combine(WORKING_FOLDER, "MODHSYN.IRX"), true);
                File.Copy(Path.Combine(pMkPsf2Struct.modulePath, "MODMIDI.IRX"), Path.Combine(WORKING_FOLDER, "MODMIDI.IRX"), true);

                // copy program
                File.Copy(makePsf2SourcePath, makePsf2DestinationPath, true);
            }
            catch (Exception ex)
            {
                vProgressStruct              = new VGMToolbox.util.ProgressStruct();
                vProgressStruct.NewNode      = null;
                vProgressStruct.FileName     = null;
                vProgressStruct.ErrorMessage = ex.Message;
                ReportProgress(0, vProgressStruct);

                return;
            }

            foreach (string f in pUniqueSqFiles)
            {
                if (!CancellationPending)
                {
                    StringBuilder sqArguments = new StringBuilder();

                    // report progress
                    int progress = (++this.fileCount * 100) / maxFiles;
                    vProgressStruct          = new VGMToolbox.util.ProgressStruct();
                    vProgressStruct.NewNode  = null;
                    vProgressStruct.FileName = f;
                    ReportProgress(progress, vProgressStruct);

                    try
                    {
                        // copy data files to working directory
                        string filePrefix      = Path.GetFileNameWithoutExtension(f);
                        string sourceDirectory = Path.GetDirectoryName(f);

                        string bdFileName = filePrefix + ".bd";
                        string hdFileName = filePrefix + ".hd";
                        string sqFileName = filePrefix + ".sq";

                        string sourceBdFile = Path.Combine(sourceDirectory, bdFileName);
                        string sourceHdFile = Path.Combine(sourceDirectory, hdFileName);
                        string sourceSqFile = Path.Combine(sourceDirectory, sqFileName);

                        string destinationBdFile = Path.Combine(WORKING_FOLDER, bdFileName);
                        string destinationHdFile = Path.Combine(WORKING_FOLDER, hdFileName);
                        string destinationSqFile = Path.Combine(WORKING_FOLDER, sqFileName);

                        File.Copy(sourceBdFile, destinationBdFile);
                        File.Copy(sourceHdFile, destinationHdFile);
                        File.Copy(sourceSqFile, destinationSqFile);

                        // write ini file
                        string       iniPath = Path.Combine(WORKING_FOLDER, "psf2.ini");
                        StreamWriter sw      = File.CreateText(iniPath);
                        sw.WriteLine("libsd.irx");
                        sw.WriteLine("modhsyn.irx");
                        sw.WriteLine("modmidi.irx");

                        // build sq.irx arguments
                        sqArguments.Append(String.IsNullOrEmpty(pMkPsf2Struct.reverb.Trim()) ?
                                           " -r=5" : String.Format(" -r={0}", pMkPsf2Struct.reverb.Trim()));
                        sqArguments.Append(String.IsNullOrEmpty(pMkPsf2Struct.depth.Trim()) ?
                                           " -d=16383" : String.Format(" -d={0}", pMkPsf2Struct.depth.Trim()));

                        sqArguments.Append(String.IsNullOrEmpty(pMkPsf2Struct.tickInterval.Trim()) ?
                                           String.Empty : String.Format(" -u={0}", pMkPsf2Struct.tickInterval.Trim()));
                        sqArguments.Append(String.IsNullOrEmpty(pMkPsf2Struct.tempo.Trim()) ?
                                           String.Empty : String.Format(" -t={0}", pMkPsf2Struct.tempo.Trim()));
                        sqArguments.Append(String.IsNullOrEmpty(pMkPsf2Struct.volume.Trim()) ?
                                           String.Empty : String.Format(" -v={0}", pMkPsf2Struct.volume.Trim()));

                        sqArguments.Append(String.Format(" -s={0} -h={1} -b={2}",
                                                         sqFileName, hdFileName, bdFileName));

                        //sw.WriteLine(String.Format("sq.irx -r=5 -d=16383 -s={0} -h={1} -b={2}",
                        //    sqFileName, hdFileName, bdFileName));

                        sw.WriteLine(String.Format("sq.irx {0}", sqArguments.ToString()));
                        sw.Close();
                        sw.Dispose();

                        // run makepsf2
                        string arguments = String.Format(" {0}.psf2 {1}", filePrefix, WORKING_FOLDER);
                        makePsf2Process           = new Process();
                        makePsf2Process.StartInfo = new ProcessStartInfo(makePsf2DestinationPath, arguments);
                        makePsf2Process.StartInfo.UseShellExecute = false;
                        makePsf2Process.StartInfo.CreateNoWindow  = true;
                        bool isSuccess = makePsf2Process.Start();
                        makePsf2Process.WaitForExit();

                        if (isSuccess)
                        {
                            vProgressStruct                = new VGMToolbox.util.ProgressStruct();
                            vProgressStruct.NewNode        = null;
                            vProgressStruct.GenericMessage = String.Format("{0}.psf2 created.", filePrefix) +
                                                             Environment.NewLine;
                            ReportProgress(Constants.ProgressMessageOnly, vProgressStruct);

                            File.Move(filePrefix + ".psf2", Path.Combine(OUTPUT_FOLDER, filePrefix + ".psf2"));
                        }

                        File.Delete(destinationBdFile);
                        File.Delete(destinationHdFile);
                        File.Delete(destinationSqFile);
                        File.Delete(iniPath);
                    }
                    catch (Exception ex2)
                    {
                        vProgressStruct              = new VGMToolbox.util.ProgressStruct();
                        vProgressStruct.NewNode      = null;
                        vProgressStruct.FileName     = f;
                        vProgressStruct.ErrorMessage = ex2.Message;
                        ReportProgress(progress, vProgressStruct);
                    }
                }
                else
                {
                    e.Cancel = true;
                    return;
                }
            } // foreach

            try
            {
                Directory.Delete(WORKING_FOLDER, true);
                File.Delete(makePsf2DestinationPath);
            }
            catch (Exception ex3)
            {
                vProgressStruct              = new VGMToolbox.util.ProgressStruct();
                vProgressStruct.NewNode      = null;
                vProgressStruct.FileName     = null;
                vProgressStruct.ErrorMessage = ex3.Message;
                ReportProgress(100, vProgressStruct);
            }
        }