public static bool Phase2Test(RvFile dbFile, RvFile testFile, EScanLevel eScanLevel, string fullDir, ThreadWorker thWrk, ref bool fileErrorAbort, out bool MatchedAlt) { MatchedAlt = false; //Debug.WriteLine("Comparing Dat File " + dbFile.TreeFullName); //Debug.WriteLine("Comparing File " + testFile.TreeFullName); int retv = DBHelper.CompareName(dbFile, testFile); if (retv != 0) { return(false); } FileType dbfileType = dbFile.FileType; FileType dbtestFile = testFile.FileType; if (dbfileType != FileType.File || dbtestFile != FileType.File) { return(false); } Populate.FromAFile(testFile, fullDir, eScanLevel, thWrk, ref fileErrorAbort); if (fileErrorAbort) { return(false); } if (testFile.GotStatus == GotStatus.FileLocked) { return(false); } return(CompareWithAlt(dbFile, testFile, out MatchedAlt)); }
private static bool NewFileFound(RvFile fileChild, RvFile dbDir, int dbIndex) { if (fileChild == null) { ReportError.SendAndShow("Error in File Scanning Code."); return(true); } // this could be an unknown file, or dirctory. // if item is a directory add the directory and call back in again // add the newly found item switch (fileChild.FileType) { case FileType.Zip: case FileType.SevenZip: dbDir.ChildAdd(fileChild, dbIndex); CheckADir(fileChild, false); return(true); case FileType.Dir: dbDir.ChildAdd(fileChild, dbIndex); CheckADir(fileChild, true); return(true); case FileType.File: // if we have not read the files CRC in the checking code, we need to read it now. if (fileChild.GotStatus != GotStatus.FileLocked) { if (!Utils.IsDeepScanned(fileChild)) { Populate.FromAFile(fileChild, dbDir.FullName, EScanLevel, _thWrk, ref _fileErrorAbort); } } dbDir.ChildAdd(fileChild, dbIndex); return(true); case FileType.ZipFile: dbDir.ChildAdd(fileChild, dbIndex); return(true); case FileType.SevenZipFile: if (fileChild.Name.EndsWith("/")) { return(false); } dbDir.ChildAdd(fileChild, dbIndex); return(true); default: throw new Exception("Unsuported file type " + fileChild.FileType); } }
/// <summary> /// Called from 5 places: /// 1: ScanFiles: main top level loop. /// 2: MatchFound: called after a ZIP/SevenZip is matched to an item in the DB, where the zip has either changed or never been scanned or level 3 scanning /// 3: MatchFound: called when an directory is matched to an item in the DB that is not from a DAT. (This is a directory not found in the main tree, as main tree dir's are processes in top level loop /// 4: NewFileFound: called after a new unmatched ZIP/SevenZip is found. /// 5: NewFileFound: called after a new unmatched DIR is found. /// </summary> /// <param name="dbDir"></param> /// <param name="report"></param> private static void CheckADir(RvFile dbDir, bool report) { if (_cacheSaveTimer.Elapsed.TotalMinutes > Settings.rvSettings.CacheSaveTimePeriod) { _thWrk.Report("Saving Cache"); DB.Write(); _thWrk.Report("Saving Cache Complete"); _cacheSaveTimer.Reset(); _cacheSaveTimer.Start(); } string fullDir = dbDir.FullName; if (report) { _thWrk.Report(new bgwText2(fullDir)); } // this is a temporary rvDir structure to store the data about the actual directory/files we are scanning // we will first populate this variable with the real file data from the directory, and then compare it // with the data in dbDir. RvFile fileDir = null; Debug.WriteLine(fullDir); FileType ft = dbDir.FileType; #region "Populate fileDir" // if we are scanning a ZIP file then populate scanDir from the ZIP file switch (ft) { case FileType.Zip: case FileType.SevenZip: fileDir = Populate.FromAZipFile(dbDir, EScanLevel, _thWrk); break; case FileType.Dir: fileDir = Populate.FromADir(dbDir, EScanLevel, _thWrk, ref _fileErrorAbort); break; default: ReportError.SendAndShow("Un supported file type in CheckADir " + ft); break; } #endregion if (fileDir == null) { ReportError.SendAndShow("Unknown Reading File Type in Dir Scanner"); return; } if (report) { _thWrk.Report(new bgwSetRange2(fileDir.ChildCount - 1)); _thWrk.Report(new bgwRange2Visible(true)); } if (!DBTypeGet.isCompressedDir(ft) && _thWrk.CancellationPending) { return; } Compare(dbDir, fileDir, report, true); }