Пример #1
0
        private static void ChdManCheck(string directory, RvFile tFile)
        {
            string filename = Path.Combine(directory, tFile.Name);

            if (!tFile.FileStatusIs(FileStatus.SHA1CHDFromHeader))
            {
                return;
            }
            _bgw.ReportProgress(0, new bgwText2(filename));

            string error;

            CHD.CHDManCheck res = CHD.ChdmanCheck(filename, _bgw, out error);
            switch (res)
            {
            case CHD.CHDManCheck.Good:
                tFile.FileStatusSet(FileStatus.SHA1CHDVerified);
                return;

            case CHD.CHDManCheck.Corrupt:
                _bgw.ReportProgress(0, new bgwShowError(filename, error));
                tFile.GotStatus = GotStatus.Corrupt;
                return;

            case CHD.CHDManCheck.CHDReturnError:
            case CHD.CHDManCheck.CHDUnknownError:
                _bgw.ReportProgress(0, new bgwShowError(filename, error));
                return;

            case CHD.CHDManCheck.ChdmanNotFound:
                return;

            case CHD.CHDManCheck.CHDNotFound:
                ReportError.Show("File: " + filename + " Error: Not Found scan Aborted.");
                _fileErrorAbort = true;
                return;

            default:
                ReportError.UnhandledExceptionHandler(error);
                return;
            }
        }
Пример #2
0
        public static void UpdateDat(object sender, DoWorkEventArgs e)
        {
            try
            {
                _bgw = sender as BackgroundWorker;
                if (_bgw == null)
                {
                    return;
                }

                Program.SyncCont = e.Argument as SynchronizationContext;
                if (Program.SyncCont == null)
                {
                    _bgw = null;
                    return;
                }


                _bgw.ReportProgress(0, new bgwText("Clearing DB Status"));
                RepairStatus.ReportStatusReset(DB.DirTree);

                _datCount = 0;

                _bgw.ReportProgress(0, new bgwText("Finding Dats"));
                RvDir datRoot = new RvDir(FileType.Dir)
                {
                    Name = "RomVault", DatStatus = DatStatus.InDatCollect
                };

                // build a datRoot tree of the DAT's in DatRoot, and count how many dats are found
                if (!RecursiveDatTree(datRoot, out _datCount))
                {
                    _bgw.ReportProgress(0, new bgwText("Dat Update Complete"));
                    _bgw             = null;
                    Program.SyncCont = null;
                    return;
                }

                _bgw.ReportProgress(0, new bgwText("Scanning Dats"));
                _datsProcessed = 0;

                // now compare the database DAT's with datRoot removing any old DAT's
                RemoveOldDats(DB.DirTree.Child(0), datRoot);

                // next clean up the File status removing any old DAT's
                RemoveOldDatsCleanUpFiles(DB.DirTree.Child(0));

                _bgw.ReportProgress(0, new bgwSetRange(_datCount - 1));

                // next add in new DAT and update the files
                UpdateDatList((RvDir)DB.DirTree.Child(0), datRoot);

                // finally remove any unneeded DIR's from the TreeView
                RemoveOldTree(DB.DirTree.Child(0));

                _bgw.ReportProgress(0, new bgwText("Updating Cache"));
                DB.Write();

                _bgw.ReportProgress(0, new bgwText("Dat Update Complete"));
                _bgw             = null;
                Program.SyncCont = null;
            }
            catch (Exception exc)
            {
                ReportError.UnhandledExceptionHandler(exc);

                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Updating Cache"));
                }
                DB.Write();
                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Complete"));
                }

                _bgw             = null;
                Program.SyncCont = null;
            }
        }
Пример #3
0
        public static void ScanFiles(object sender, DoWorkEventArgs e)
        {
#if !Debug
            try
            {
#endif
            _fileErrorAbort = false;
            _cacheSaveTimer = new Stopwatch();
            _cacheSaveTimer.Reset();
            if (Settings.CacheSaveTimerEnabled)
            {
                _cacheSaveTimer.Start();
            }

            _bgw = sender as BackgroundWorker;
            if (_bgw == null)
            {
                return;
            }

            Program.SyncCont = e.Argument as SynchronizationContext;
            if (Program.SyncCont == null)
            {
                _bgw = null;
                return;
            }


            _bgw.ReportProgress(0, new bgwText("Clearing DB Status"));
            RepairStatus.ReportStatusReset(DB.DirTree);

            _bgw.ReportProgress(0, new bgwText("Finding Dir's to Scan"));
            //Next get a list of all the directories to be scanned
            List <RvDir> lstDir = new List <RvDir>();
            DBHelper.GetSelectedDirList(ref lstDir);


            _bgw.ReportProgress(0, new bgwText("Scanning Dir's"));
            _bgw.ReportProgress(0, new bgwSetRange(lstDir.Count - 1));
            //Scan the list of directories.
            for (int i = 0; i < lstDir.Count; i++)
            {
                _bgw.ReportProgress(i);
                _bgw.ReportProgress(0, new bgwText("Scanning Dir : " + lstDir[i].FullName));
                string lDir = lstDir[i].FullName;
                Console.WriteLine(lDir);
                if (Directory.Exists(lDir))
                {
                    CheckADir(lstDir[i], true);
                }
                else
                {
                    MarkAsMissing(lstDir[i]);
                }

                if (_bgw.CancellationPending || _fileErrorAbort)
                {
                    break;
                }
            }

            _bgw.ReportProgress(0, new bgwText("Updating Cache"));
            DB.Write();


            _bgw.ReportProgress(0, new bgwText("File Scan Complete"));

            _bgw             = null;
            Program.SyncCont = null;
#if !Debug
        }

        catch (Exception exc)
        {
            ReportError.UnhandledExceptionHandler(exc);

            if (_bgw != null)
            {
                _bgw.ReportProgress(0, new bgwText("Updating Cache"));
            }
            DB.Write();
            if (_bgw != null)
            {
                _bgw.ReportProgress(0, new bgwText("Complete"));
            }

            _bgw             = null;
            Program.SyncCont = null;
        }
#endif
        }
Пример #4
0
        public static void ScanFiles(object sender, DoWorkEventArgs e)
        {
            try
            {
                _bgw = sender as BackgroundWorker;
                if (_bgw == null)
                {
                    return;
                }

                Program.SyncCont = e.Argument as SynchronizationContext;
                if (Program.SyncCont == null)
                {
                    _bgw = null;
                    return;
                }

                _bgw.ReportProgress(0, new bgwText("Clearing DB Status"));
                RepairStatus.ReportStatusReset(DB.DirTree);

                List <RvFile> lstRomTableSortedCRCSize;
                List <RvFile> lstRomTableSortedSHA1CHD;

                _bgw.ReportProgress(0, new bgwText("Loading Rom List"));
                DBHelper.GetSelectedFilesSortCRCSize(out lstRomTableSortedCRCSize);
                DBHelper.GetSelectedFilesSortSHA1CHD(out lstRomTableSortedSHA1CHD);

                _bgw.ReportProgress(0, new bgwText("Scanning for Fixes"));
                _bgw.ReportProgress(0, new bgwSetRange(lstRomTableSortedCRCSize.Count));

                int romIndex0 = 0;
                int romIndex1 = 1;
                while (romIndex1 < lstRomTableSortedCRCSize.Count)
                {
                    if (romIndex1 % 100 == 0)
                    {
                        _bgw.ReportProgress(romIndex1);
                    }

                    if (!ArrByte.bCompare(lstRomTableSortedCRCSize[romIndex0].CRC, lstRomTableSortedCRCSize[romIndex1].CRC) || (lstRomTableSortedCRCSize[romIndex0].Size != lstRomTableSortedCRCSize[romIndex1].Size))
                    {
                        ListCheck(lstRomTableSortedCRCSize, romIndex0, romIndex1 - romIndex0);
                        romIndex0 = romIndex1;
                    }
                    romIndex1++;
                }

                ListCheck(lstRomTableSortedCRCSize, romIndex0, romIndex1 - romIndex0);


                _bgw.ReportProgress(0, new bgwSetRange(lstRomTableSortedSHA1CHD.Count));

                romIndex0 = 0;
                romIndex1 = 1;
                while (romIndex1 < lstRomTableSortedSHA1CHD.Count)
                {
                    if (romIndex1 % 100 == 0)
                    {
                        _bgw.ReportProgress(romIndex1);
                    }

                    if (!ArrByte.bCompare(lstRomTableSortedSHA1CHD[romIndex0].SHA1CHD, lstRomTableSortedSHA1CHD[romIndex1].SHA1CHD))
                    {
                        ListCheckSHA1CHD(lstRomTableSortedSHA1CHD, romIndex0, romIndex1 - romIndex0);
                        romIndex0 = romIndex1;
                    }
                    romIndex1++;
                }

                ListCheckSHA1CHD(lstRomTableSortedSHA1CHD, romIndex0, romIndex1 - romIndex0);


                _bgw             = null;
                Program.SyncCont = null;
            }
            catch (Exception exc)
            {
                ReportError.UnhandledExceptionHandler(exc);

                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Updating Cache"));
                }
                DB.Write();
                if (_bgw != null)
                {
                    _bgw.ReportProgress(0, new bgwText("Complete"));
                }

                _bgw             = null;
                Program.SyncCont = null;
            }
        }