示例#1
0
        private void ParseSubdirectory(Path subdirectoryPath, Directory parentDirectory)
        {
            subdirectoryPath = subdirectoryPath.DeleteBottomDirectory();

            PathParser    pathParser = new PathParser(subdirectoryPath);
            List <string> parsedPath = pathParser.GetContent();

            if (parsedPath.Count == 1)
            {
                parentDirectory.Files.Add(new File(parsedPath[0]));
            }
            else
            {
                string directoryName = parsedPath[0];

                Directory subdirectory;
                if (parentDirectory.ContainsSubdirectory(directoryName))
                {
                    subdirectory = parentDirectory.GetSubdirectory(directoryName);
                }
                else
                {
                    subdirectory = new Directory(directoryName);
                    parentDirectory.AddSubdirectory(subdirectory);
                }

                ParseSubdirectory(subdirectoryPath, subdirectory);
            }
        }
示例#2
0
        private Directory GetRootDirectory(Path path)
        {
            //root directory is a general directory that every path must contain
            PathParser pathParser    = new PathParser(path.ToString());
            string     directoryName = pathParser.GetContent()[0];

            return(new Directory(directoryName));
        }