private static bool RecursiveDatTree(RvFile tDir, out int datCount) { datCount = 0; string strPath = RvFile.GetDatPhysicalPath(tDir.DatTreeFullName); if (!Directory.Exists(strPath)) { ReportError.Show($"Path: {strPath} Not Found."); return(false); } DirectoryInfo oDir = new DirectoryInfo(strPath); List <FileInfo> lFilesIn = new List <FileInfo>(); FileInfo[] oFilesIn = oDir.GetFiles("*.dat"); lFilesIn.AddRange(oFilesIn); oFilesIn = oDir.GetFiles("*.xml"); lFilesIn.AddRange(oFilesIn); datCount += lFilesIn.Count; foreach (FileInfo file in lFilesIn) { RvDat tDat = new RvDat(); tDat.SetData(RvDat.DatData.DatRootFullName, Path.Combine(tDir.DatTreeFullName, file.Name)); tDat.TimeStamp = file.LastWriteTime; // this works passing in the full DirectoryName of the Dat, because the rules // has a directory separator character added to the end of them, // so they match up to the directory name in this full Directory Name. string datRootFullName = tDat.GetData(RvDat.DatData.DatRootFullName); DatRule datRule = DatReader.FindDatRule(datRootFullName); tDat.MultiDatOverride = datRule.MultiDATDirOverride; tDat.UseDescriptionAsDirName = datRule.UseDescriptionAsDirName; tDat.SingleArchive = datRule.SingleArchive; tDat.SubDirType = datRule.SubDirType; tDir.DirDatAdd(tDat); } if (tDir.DirDatCount > 1) { for (int i = 0; i < tDir.DirDatCount; i++) { tDir.DirDat(i).MultiDatsInDirectory = true; } } DirectoryInfo[] oSubDir = oDir.GetDirectories(); foreach (DirectoryInfo t in oSubDir) { RvFile cDir = new RvFile(FileType.Dir) { Name = t.Name, DatStatus = DatStatus.InDatCollect }; int index = tDir.ChildAdd(cDir); RecursiveDatTree(cDir, out int retDatCount); datCount += retDatCount; if (retDatCount == 0) { tDir.ChildRemove(index); } } return(true); }
public static RvFile ConvertFromExternalDat(DatHeader datHeaderExternal, RvDat datFile) { RvFile newDirFromExternal = new RvFile(FileType.Dir); RvDat newDatFromExternal = new RvDat(); newDatFromExternal.SetData(RvDat.DatData.DatRootFullName, datFile.GetData(RvDat.DatData.DatRootFullName)); newDatFromExternal.TimeStamp = datFile.TimeStamp; newDatFromExternal.Status = DatUpdateStatus.Correct; newDatFromExternal.SetData(RvDat.DatData.DatName, datHeaderExternal.Name); newDatFromExternal.SetData(RvDat.DatData.RootDir, datHeaderExternal.RootDir); newDatFromExternal.SetData(RvDat.DatData.Description, datHeaderExternal.Description); newDatFromExternal.SetData(RvDat.DatData.Category, datHeaderExternal.Category); newDatFromExternal.SetData(RvDat.DatData.Version, datHeaderExternal.Version); newDatFromExternal.SetData(RvDat.DatData.Date, datHeaderExternal.Date); newDatFromExternal.SetData(RvDat.DatData.Author, datHeaderExternal.Author); newDatFromExternal.SetData(RvDat.DatData.Email, datHeaderExternal.Email); newDatFromExternal.SetData(RvDat.DatData.HomePage, datHeaderExternal.Homepage); newDatFromExternal.SetData(RvDat.DatData.URL, datHeaderExternal.URL); newDatFromExternal.SetData(RvDat.DatData.DirSetup, datHeaderExternal.Dir); newDatFromExternal.SetData(RvDat.DatData.Header, datHeaderExternal.Header); newDatFromExternal.MultiDatsInDirectory = datFile.MultiDatsInDirectory; newDatFromExternal.MultiDatOverride = datFile.MultiDatOverride; newDirFromExternal.Dat = newDatFromExternal; HeaderFileType headerFileType = FileHeaderReader.FileHeaderReader.GetFileTypeFromHeader(datHeaderExternal.Header); CopyDir(datHeaderExternal.BaseDir, newDirFromExternal, newDatFromExternal, headerFileType, false); return(newDirFromExternal); }