Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public SlynchyDirectory(DirectorySpec spec, string rootDirectory, SlynchyDirectory parent, string path)
        {
            Spec          = spec;
            RootDirectory = rootDirectory;
            IsRoot        = false;

            Info = new DirectoryInfo(path);
            GetDirectoryFiles();

            //recursive directory and file object tree here
            GetSubDirectoryInfo();
        }
Exemplo n.º 4
0
        public SlynchyDirectory GetDirectoryNode(string relDirPath)
        {
            var DirNode = new SlynchyDirectory();

            if (RelDirectoryExists(relDirPath))
            {
                var DirNames = Utility.DirectoryParts(relDirPath);
                int index    = 1;
                DirNode = GetSubDirectoryNode(RootSlynchyDirectory, DirNames, index);
            }

            return(DirNode);
        }
Exemplo n.º 5
0
        public void GetSubDirectoryInfo()
        {
            SubDirectoryInfoList = new List <SlynchyDirectory>();
            var dirNames = Directory.EnumerateDirectories(Info.FullName);

            foreach (string dirName in dirNames)
            {
                string path             = Path.Combine(Info.FullName, dirName);
                var    slynchyDirectory = new SlynchyDirectory(Spec, RootDirectory, this, path);
                if (!IsSpecDirectory(Spec, path))
                {
                    slynchyDirectory.Exclude = true;
                }
                SubDirectoryInfoList.Add(slynchyDirectory);
            }
        }
Exemplo n.º 6
0
 public SlynchyDirectory GetSubDirectoryNode(SlynchyDirectory node, string[] dirNames, int index)
 {
     if (index > dirNames.Length - 1)
     {
         return(node);
     }
     foreach (var dirInfo in node.SubDirectoryInfoList)
     {
         var LastDirectoryPart = dirInfo.LastDirectoryPart();
         var dirLevelName      = dirNames[index];
         if (LastDirectoryPart.Equals(dirLevelName) &&
             !dirInfo.Exclude)
         {
             return(GetSubDirectoryNode(dirInfo, dirNames, index + 1));
         }
     }
     return(null);
 }
Exemplo n.º 7
0
        private void PopulateSubDirs(FileTreeNode aNode, SlynchyDirectory sDir, bool fullTree)
        {
            foreach (var subDir in sDir.SubDirectoryInfoList)
            {
                if (!subDir.Exclude)
                {
                    var          SubDirName = "\\" + subDir.LastDirectoryPart(subDir.Info.Name);
                    FileTreeNode ChildNode  = new FileTreeNode(false, SubDirName, 0, 1);
                    aNode.Nodes.Add(ChildNode);

                    PopulateFiles(ChildNode, subDir, fullTree);

                    Application.DoEvents();
                    PopulateSubDirs(ChildNode, subDir, fullTree);
                }
            }
            Application.DoEvents();
        }
Exemplo n.º 8
0
        public void GetUncommonSubDirs(SlynchyDirectory node, List <SlynchyDirectoryTree> otherTrees)
        {
            foreach (var snode in node.SubDirectoryInfoList)
            {
                if (!snode.Exclude)
                {
                    var DirName    = snode.RelativeDirectory();
                    var IsUnCommon = false;
                    foreach (var tree in otherTrees)
                    {
                        if (!tree.RelDirectoryExists(DirName))
                        {
                            IsUnCommon = true;
                        }
                    }
                    if (IsUnCommon)
                    {
                        //Make sure directory isn't already in list
                        if (!IsInUncommonDirList(DirName))
                        {
                            //If not in list, add
                            var uDir = new UncommonDirectory();
                            uDir.RelDir = DirName;
                            UDirs.Add(uDir);
                            foreach (var tree in otherTrees)
                            {
                                if (tree.RelDirectoryExists(DirName))
                                {
                                    uDir.InTrees.Add(tree);
                                }
                                else
                                {
                                    uDir.NotInTrees.Add(tree);
                                }
                            }
                        }
                    }
                    GetUncommonSubDirs(snode, otherTrees);
                }
            }

            //Get the uncommon and unmatched files
            GetUncommonUnmatchedFiles(node, otherTrees);
        }
Exemplo n.º 9
0
 private void PopulateFiles(FileTreeNode aNode, SlynchyDirectory sDir, bool fullTree)
 {
     foreach (var fileInfo in sDir.DirectoryFileInfoList)
     {
         var FileName = fileInfo.Info.Name;
         if (fullTree)
         {
             aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2));
         }
         else
         {
             if (!fileInfo.Exclude)
             {
                 aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2));
             }
         }
     }
     Application.DoEvents();
 }
Exemplo n.º 10
0
 private void PopulateFiles(FileTreeNode aNode,
                            SlynchyDirectory sDir, Label countDisplay, ref int count, bool fullTree)
 {
     count            += sDir.DirectoryFileInfoList.Count;
     countDisplay.Text = count.ToString() + " Files";
     foreach (var fileInfo in sDir.DirectoryFileInfoList)
     {
         if (fullTree)
         {
             var FileName = fileInfo.Info.Name;
             aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2));
         }
         else
         {
             if (!fileInfo.Exclude)
             {
                 var FileName = fileInfo.Info.Name;
                 aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2));
             }
         }
     }
     Application.DoEvents();
 }
Exemplo n.º 11
0
        private void PopulateSubDirs(FileTreeNode aNode,
                                     SlynchyDirectory sDir, Label dirCountDisplay, ref int dirCount,
                                     Label fileCountDisplay, ref int fileCount, bool fullTree)
        {
            foreach (var subDir in sDir.SubDirectoryInfoList)
            {
                if (!subDir.Exclude)
                {
                    var          SubDirName = "\\" + subDir.LastDirectoryPart(subDir.Info.Name);
                    FileTreeNode ChildNode  = new FileTreeNode(false, SubDirName, 0, 1);
                    aNode.Nodes.Add(ChildNode);
                    dirCount++;
                    dirCountDisplay.Text = dirCount.ToString() + " Directories";

                    PopulateFiles(ChildNode, subDir, fileCountDisplay, ref fileCount, fullTree);

                    Application.DoEvents();
                    PopulateSubDirs(ChildNode, subDir, dirCountDisplay, ref dirCount,
                                    fileCountDisplay, ref fileCount, fullTree);
                }
            }
            Application.DoEvents();
        }
Exemplo n.º 12
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
 public void ScanTree()
 {
     //This scans files and directories, includes them in tree
     RootSlynchyDirectory = new SlynchyDirectory(Spec, RootDirectoryPath, RootDirectoryPath);
     RootSlynchyDirectory.ExcludeFilesInExcludedDirs();
 }