public bool FileNameInFileList(SlynchyDirectory node, SlynchyFile fileInfo) { var result = false; var FileName = fileInfo.Info.Name; foreach (var compInfo in node.DirectoryFileInfoList) { if (!compInfo.Exclude) { if (compInfo.Info.Name.Equals(FileName)) { result = true; //Is it different? if (compInfo.Info.Length != fileInfo.Info.Length) { var rootDirPath = node.RootDirectory; var Tree = GetRootDirectoryTree(rootDirPath); var relDir = node.RelativeDirectory(); AddDifferentFile(relDir, Tree, compInfo); } } } } return(result); }
public SlynchyFile GetFileInfo(string relDir, string fileName) { var node = GetDirectoryNode(relDir); var fileInfo = new SlynchyFile(); foreach (var fInfo in node.DirectoryFileInfoList) { if (fInfo.Info.Name.Equals(fileName)) { fileInfo = fInfo; } } return(fileInfo); }
public void GetDirectoryFiles() { DirectoryFileInfoList = new List <SlynchyFile>(); var fileNames = Directory.EnumerateFiles(Info.FullName); foreach (var filePath in fileNames) { var fileInfo = new SlynchyFile(filePath); if (!IsSpecFile(Spec, fileInfo)) { fileInfo.Exclude = true; } DirectoryFileInfoList.Add(fileInfo); } }
public void AddDifferentFileSpec(SlynchyDirectoryTree tree, SlynchyFile info) { var IsInList = false; foreach (var spec in Specs) { if (spec.Tree.RootDirectoryPath.Equals(tree.RootDirectoryPath)) { IsInList = true; } } if (!IsInList) { var spec = new FileSpecs(tree, info); Specs.Add(spec); } }
public bool IsSpecFile(DirectorySpec spec, SlynchyFile info) { if (spec.IncludedFileExtensions.Count > 0) { if (spec.IncludedFileExtensions.Contains(info.Info.Extension)) { return(true); } else { return(false); } } if (spec.FileNameExcludes.Count > 0) { if (spec.FileNameExcludes.Contains(info.Info.Name)) { return(false); } } if (spec.FilePathExcludes.Count > 0) { if (spec.FilePathExcludes.Contains(info.Info.FullName)) { return(false); } } if (spec.DirFileExcludes.Count > 0) { var relDir = RelativeDirectory(info.Info.DirectoryName); var relPathFile = Path.Combine(relDir, info.Info.Name); if (spec.DirFileExcludes.Contains(relPathFile)) { return(false); } } return(true); }
public FileSpecs(SlynchyDirectoryTree tree, SlynchyFile info) { Tree = tree; Info = info; }
//tree is the tree for the comparison file, with data "info" public void AddDifferentFile(string relDirectoryPath, SlynchyDirectoryTree tree, SlynchyFile info) { var FoundRelDir = false; foreach (var dFile in DFiles) { if (dFile.RelDir.Equals(relDirectoryPath) && dFile.FileName.Equals(info.Info.Name)) { FoundRelDir = true; dFile.AddDifferentFileSpec(tree, info); } } if (!FoundRelDir) { var newDiffFiles = new DifferentFiles(); newDiffFiles.RelDir = relDirectoryPath; newDiffFiles.FileName = info.Info.Name; newDiffFiles.AddDifferentFileSpec(tree, info); DFiles.Add(newDiffFiles); } }