Beispiel #1
0
        public void ConvertBinFiles()
        {
            if (!Initialized)
            {
                Error?.Invoke("Code not Initialized");
                return;
            }

            int counter = 0;
            var binList = new DirectoryInfo(SourceDirectory).GetFiles("*.bin", SearchOption.TopDirectoryOnly);

            ActionStart?.Invoke(Actions.Convert, binList.Count());

            foreach (var binFile in binList)
            {
                counter++;

                FileStart?.Invoke(binFile.Name);
                Update?.Invoke(counter, binList.Count(), binFile.Name);

                if (ConvertBinToIso(binFile.FullName))
                {
                    FileOK?.Invoke(binFile.Name);
                }
                else
                {
                    FileNOK?.Invoke(binFile.Name);
                    File.Move(binFile.FullName, Path.Combine(TargetFailureDirectory, binFile.Name));
                    if (File.Exists(Path.ChangeExtension(binFile.FullName, ".cue")))
                    {
                        File.Move(Path.ChangeExtension(binFile.FullName, ".cue"), Path.Combine(TargetFailureDirectory, Path.ChangeExtension(binFile.Name, ".cue")));
                    }
                }

                FileStop?.Invoke(binFile.Name);
            }

            ActionStop?.Invoke(Actions.Convert);
        }
Beispiel #2
0
        public void ExtractZipFiles()
        {
            if (!Initialized)
            {
                Error?.Invoke("Code not Initialized");
                return;
            }

            int counter = 0;
            var zipList = new DirectoryInfo(SourceDirectory).GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(x => "*.7z,*.zip,*.rar".Contains(x.Extension.ToLower()));

            ActionStart?.Invoke(Actions.Unzip, zipList.Count());

            foreach (var zipFile in zipList)
            {
                counter++;

                FileStart?.Invoke(zipFile.Name);
                Update?.Invoke(counter, zipList.Count(), zipFile.Name);

                if (ExtractZip(zipFile.FullName))
                {
                    FileOK?.Invoke(zipFile.Name);
                    File.Delete(zipFile.FullName);
                }
                else
                {
                    FileNOK?.Invoke(zipFile.Name);
                    File.Move(zipFile.FullName, Path.Combine(TargetFailureDirectory, zipFile.Name));
                }

                FileStop?.Invoke(zipFile.Name);
            }

            ActionStop?.Invoke(Actions.Unzip);
        }
Beispiel #3
0
        private bool IdentifyIsoFiles()
        {
            if (!Initialized)
            {
                Error?.Invoke("Code not Initialized");
                return(false);
            }

            int counter = 0;
            var isoList = new DirectoryInfo(SourceDirectory).GetFiles("*.iso", SearchOption.TopDirectoryOnly);

            ActionStart?.Invoke(Actions.Identify, isoList.Count());

            if (isoList.Count() == 0)
            {
                Error?.Invoke("No ISO files found in the Source Directory");
                return(false);
            }

            LoadGameMapping(out Dictionary <string, string> mapping);

            foreach (var isoFile in isoList)
            {
                counter++;

                FileStart?.Invoke(isoFile.Name);
                Update?.Invoke(counter, isoList.Count(), isoFile.Name);

                string exception = IdentifyIso(isoFile, out string id);
                if (string.IsNullOrEmpty(exception))
                {
                    string newPath = Path.Combine(TargetSuccessDirectory, GetNewFilename(mapping, id, isoFile.Name));
                    if (isoFile.FullName == newPath)
                    {
                        FileOK?.Invoke(isoFile.Name);
                    }
                    else
                    {
                        if (File.Exists(newPath))
                        {
                            Error?.Invoke("Duplicate File");
                            FileNOK?.Invoke(isoFile.Name);
                            MoveFailedFile(isoFile.FullName, Path.Combine(TargetFailureDirectory, isoFile.Name));
                        }
                        else
                        {
                            FileRename?.Invoke(isoFile.Name, Path.GetFileName(newPath));
                            FileOK?.Invoke(isoFile.Name);
                            File.Move(isoFile.FullName, newPath);
                        }
                    }
                }
                else
                {
                    Error?.Invoke(exception);
                    FileNOK?.Invoke(isoFile.Name);
                    MoveFailedFile(isoFile.FullName, Path.Combine(TargetFailureDirectory, isoFile.Name));
                }

                FileStop?.Invoke(isoFile.Name);
            }

            SaveGameMapping(mapping);

            ActionStop?.Invoke(Actions.Identify);

            return(true);
        }