/// <summary> /// Find directory /// </summary> /// <param name="subpath">canonized path</param> /// <returns>directory or null if was not found</returns> public ArchiveDirectoryEntry GetDirectory(string subpath) { if (subpath == null) { throw new ArgumentNullException(nameof(subpath)); } if (subpath == "") { return(this); } // Split to local dir name and rest of the path int slashIx = subpath.IndexOf('/'); string localDirectoryName = slashIx < 0 ? subpath : subpath.Substring(0, slashIx); string restOfThePath = slashIx < 0 ? null : subpath.Substring(slashIx + 1); // Get local directory ArchiveDirectoryEntry dir = null; if (!directories.TryGetValue(localDirectoryName, out dir)) { return(null); } // Return or recurse return(restOfThePath == null ? dir : dir.GetDirectory(restOfThePath)); }
/// <summary> /// Search directory from the read-only directory index. /// </summary> /// <param name="path"></param> /// <returns></returns> public virtual IDirectoryContents GetDirectoryContents(string path) { if (IsDisposing) { throw new ObjectDisposedException(GetType().FullName); } if (path == null) { path = ""; } string canonizedPath = CanonizePath(path); ArchiveDirectoryEntry dir = root.GetDirectory(canonizedPath); return((IDirectoryContents)dir ?? NotFoundDirectoryContents.Singleton); }