private void AddEmptyDirectory(string directory) { Folder childFolder = null; // Note: If there is a hierarchy of folders that only contain // folders, then the folders will not be added as part of the // files, therefore we need to add the entire hierarchy. while (!folders.ContainsKey(directory)) { var newFolder = new Folder(directory); if (childFolder != null) { newFolder.Add(childFolder); } folders.Add(directory, newFolder); childFolder = newFolder; directory = GetParentDirectoryPath(directory); } if (childFolder != null) { folders[directory].Add(childFolder); } }
private void AddFile(string file) { var parentPath = GetParentDirectoryPath(file); Folder childFolder = null; while (!folders.ContainsKey(parentPath)) { var newFolder = new Folder(parentPath); if (childFolder != null) { newFolder.Add(childFolder); } folders.Add(parentPath, newFolder); childFolder = newFolder; parentPath = GetParentDirectoryPath(parentPath); } if (childFolder != null) { folders[parentPath].Add(childFolder); } var fileFolder = folders[GetParentDirectoryPath(file)]; fileFolder.Add(new File(file)); }
private void AddFile(string file) { var parentPath = GetParentDirectoryPath(file); Folder childFolder = null; while (!folders.ContainsKey(parentPath)) { var newFolder = new Folder(parentPath); if (childFolder != null) newFolder.Add(childFolder); folders.Add(parentPath, newFolder); childFolder = newFolder; parentPath = GetParentDirectoryPath(parentPath); } if (childFolder != null) folders[parentPath].Add(childFolder); var fileFolder = folders[GetParentDirectoryPath(file)]; fileFolder.Add(new File(file)); }
private void AddEmptyDirectory(string directory) { Folder childFolder = null; // Note: If there is a hierarchy of folders that only contain // folders, then the folders will not be added as part of the // files, therefore we need to add the entire hierarchy. while (!folders.ContainsKey(directory)) { var newFolder = new Folder(directory); if (childFolder != null) newFolder.Add(childFolder); folders.Add(directory, newFolder); childFolder = newFolder; directory = GetParentDirectoryPath(directory); } if (childFolder != null) folders[directory].Add(childFolder); }