public D2pDirectory TryGetDirectory(string directory) { string[] directoriesName = directory.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); if (directoriesName.Length == 0) { return(null); } D2pDirectory current = null; m_rootDirectories.TryGetValue(directoriesName[0], out current); if (current == null) { return(null); } foreach (string dir in directoriesName.Skip(1)) { if (!current.HasDirectory(dir)) { return(null); } current = current.TryGetDirectory(dir); } return(current); }
public D2pDirectory[] GetDirectoriesTree(string directory) { var result = new List <D2pDirectory>(); string[] directoriesName = directory.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); if (directoriesName.Length == 0) { return(new D2pDirectory[0]); } D2pDirectory current = null; m_rootDirectories.TryGetValue(directoriesName[0], out current); if (current == null) { return(new D2pDirectory[0]); } result.Add(current); foreach (string dir in directoriesName.Skip(1)) { if (!current.HasDirectory(dir)) { return(result.ToArray()); } current = current.TryGetDirectory(dir); result.Add(current); } return(result.ToArray()); }