Nemerle.VisualStudio.Project.NemerleProjectNode.CreateFolderNodes C# (CSharp) Method

CreateFolderNodes() public method

Walks the subpaths of a project relative path and checks if the folder nodes hierarchy is already there, if not creates it.
public CreateFolderNodes ( string path ) : HierarchyNode
path string Path of the folder, can be relative to project or absolute
return HierarchyNode
        public override HierarchyNode CreateFolderNodes(string path)
        {
            ErrorHelper.ThrowIsNullOrEmpty(path, "path");

            if (Path.IsPathRooted(path))
            {
                // Ensure we are using a relative path
                if (String.Compare(ProjectFolder, 0, path, 0, ProjectFolder.Length, StringComparison.OrdinalIgnoreCase) == 0)
                    path = path.Substring(ProjectFolder.Length);
                else
                {
                    Debug.Assert(false, "Folder path is rooted, but not subpath of ProjectFolder.");
                }
            }

            string[] parts;
            HierarchyNode curParent;

            parts = path.Split(Path.DirectorySeparatorChar);
            path = String.Empty;
            curParent = this;

            // now we have an array of subparts....
            for (int i = 0; i < parts.Length; i++)
            {
                if (parts[i].Length > 0)
                {
                    path += parts[i] + "\\";
                    curParent = VerifySubFolderExists(path, curParent);
                }
            }

            return curParent;
        }