Пример #1
0
        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);
        }
Пример #2
0
        public void CopyNodeTree(SlynchyDirectory sNode, string destCopyPath)
        {
            //Copy files
            var fullSourcePath = sNode.RootDirectory + sNode.RelativeDirectory();

            foreach (var info in sNode.DirectoryFileInfoList)
            {
                if (!info.Exclude)
                {
                    var sourceFilePath = Path.Combine(fullSourcePath, info.Info.Name);
                    var destFilePath   = Path.Combine(destCopyPath, info.Info.Name);
                    if (!File.Exists(destFilePath))
                    {
                        File.Copy(sourceFilePath, destFilePath);
                    }
                }
            }

            //Make subdirectories and call CopyNodeTree on those nodes
            foreach (var dir in sNode.SubDirectoryInfoList)
            {
                if (!dir.Exclude)
                {
                    var subDirPath = destCopyPath + dir.Info.Name;
                    Directory.CreateDirectory(subDirPath);
                    CopyNodeTree(dir, subDirPath);
                }
            }
        }
Пример #3
0
        public void GetUncommonUnmatchedFiles(SlynchyDirectory node, List <SlynchyDirectoryTree> otherTrees)
        {
            //Files that don't appear in all trees (in the same relative directory)
            //Files that are not the same in trees they appear (in the same relative directory)
            //  This is integrated with the directory tree scan, it just compares the files
            //  in a directory node of a tree with the same relative path node of different
            //  trees.  The directory scans drive the round-robin comparison.
            var DirName   = node.RelativeDirectory();
            var BaseFiles = node.DirectoryFileInfoList;

            foreach (var tree in otherTrees)
            {
                var BaseNode = node;
                var CompNode = tree.RootSlynchyDirectory;

                if (!node.IsRoot)
                {
                    CompNode = tree.GetDirectoryNode(DirName);
                    if (CompNode != null && CompNode.Spec != null)
                    {
                        foreach (var fileInfo in BaseNode.DirectoryFileInfoList)
                        {
                            if (!fileInfo.Exclude)
                            {
                                var FileName = fileInfo.Info.Name;
                                if (!FileNameInFileList(CompNode, fileInfo))
                                {
                                    //add to uncommon list
                                    SetUncommonFile(DirName, FileName, tree);
                                }
                            }
                        }
                    }
                }
            }
        }