GetDirectories() public abstract method

public abstract GetDirectories ( ) : System.IO.Abstractions.DirectoryInfoBase[]
return System.IO.Abstractions.DirectoryInfoBase[]
Ejemplo n.º 1
0
 internal static IDictionary<string, DirectoryInfoBase> GetDirectories(DirectoryInfoBase info)
 {
     if (info == null)
     {
         return null;
     }
     return info.GetDirectories().ToDictionary(d => d.Name, StringComparer.OrdinalIgnoreCase);
 }
Ejemplo n.º 2
0
        private bool CollectDirectories(DirectoryInfoBase directory, INode rootNode, GeneralTree<INode> tree)
        {
            List<GeneralTree<INode>> collectedNodes = new List<GeneralTree<INode>>();

            foreach (DirectoryInfoBase subDirectory in directory.GetDirectories().OrderBy(di => di.Name))
            {
                GeneralTree<INode> subTree = this.Crawl(subDirectory, rootNode);
                if (subTree != null)
                {
                    collectedNodes.Add(subTree);
                }
            }

            foreach (var node in collectedNodes)
            {
                tree.Add(node);
            }

            return collectedNodes.Count > 0;
        }
Ejemplo n.º 3
0
        internal static void Copy(string sourcePath,
                                  string destinationPath,
                                  DirectoryInfoBase sourceDirectory,
                                  DirectoryInfoBase destinationDirectory,
                                  Func<string, DirectoryInfoBase> createDirectoryInfo,
                                  bool skipScmFolder)
        {
            // Skip hidden directories and directories that begin with .
            if (skipScmFolder && IsSourceControlFolder(sourceDirectory))
            {
                return;
            }

            if (!destinationDirectory.Exists)
            {
                destinationDirectory.Create();
            }

            foreach (var sourceFile in sourceDirectory.GetFiles())
            {
                string path = GetDestinationPath(sourcePath, destinationPath, sourceFile);

                sourceFile.CopyTo(path, overwrite: true);
            }

            var destDirectoryLookup = GetDirectories(destinationDirectory);
            foreach (var sourceSubDirectory in sourceDirectory.GetDirectories())
            {
                DirectoryInfoBase targetSubDirectory;
                if (!destDirectoryLookup.TryGetValue(sourceSubDirectory.Name, out targetSubDirectory))
                {
                    string path = GetDestinationPath(sourcePath, destinationPath, sourceSubDirectory);
                    targetSubDirectory = createDirectoryInfo(path);
                }

                Copy(sourcePath, destinationPath, sourceSubDirectory, targetSubDirectory, createDirectoryInfo, skipScmFolder);
            }
        }