public void ICompressedArchiveAccess_ListWithNullArchive_ThrowsArgumentNullException() { ICompressedArchiveAccess archive = null; Assert.Throws <ArgumentNullException>(() => archive.ListEntries(null, includeContainers: false)); Assert.Throws <ArgumentNullException>(() => archive.ListContents(null, includeContainers: false)); }
/// <summary> /// List the contents of the given compressed archive. /// </summary> /// <param name="compressedArchiveAccess">An instance of <see cref="ICompressedArchiveAccess"/> whose contents are to be listed.</param> /// <param name="locationInArchive">A location relative to the root of the archive. The special values <c>null</c>, <c>string.Empty</c>, '\', '/', or '.' indicate the root. Otherwise, must end with a directory separator character.</param> /// <param name="includeContainers">If <c>true</c>, include entries that may contain other entries, such as other compressed archives and directories.</param> /// <param name="recurse">If <c>true</c>, list all contents from <paramref name="locationInArchive"/> and below, recursively. The contents of nested archives will also be listed.</param> /// <returns>The list of entries, which may include entries that could contain more items, depending on the value of <paramref name="includeContainers"/>. /// Entry names are always relative to <paramref name="compressedArchiveAccess"/>. Path separators will be normalized to forward slash.</returns> /// <remarks>NOTE: Large and /or deeply nested archives may incur performance and disk penalties. Use with care!</remarks> /// <exception cref="ArgumentNullException">Thrown if <paramref name="compressedArchiveAccess"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="locationInArchive"/> is malformed i.e. is not null or empty, or does not end with a directory separator character.</exception> /// <exception cref="FileNotFoundException">Thrown if <paramref name="locationInArchive"/> identifies a nested archive that cannot be located.</exception> public static IEnumerable <string> ListContents(this ICompressedArchiveAccess compressedArchiveAccess, string locationInArchive, bool includeContainers, bool recurse) { var entries = compressedArchiveAccess.ListEntries(locationInArchive, includeContainers, recurse); var contents = entries.Select(e => e.Name); return(contents); }
/// <summary> /// List the contents of the given compressed archive. /// </summary> /// <param name="compressedArchiveAccess">An instance of <see cref="ICompressedArchiveAccess"/> whose contents are to be listed.</param> /// <param name="locationInArchive">A location relative to the root of the archive. The special values <c>null</c>, <c>string.Empty</c>, '\', '/', or '.' indicate the root. Otherwise, must end with a directory separator character.</param> /// <param name="includeContainers">If <c>true</c>, include entries that may contain other entries, such as other compressed archives and directories.</param> /// <returns>The list of entries, which may include entries that could contain more items, depending on the value of <paramref name="includeContainers"/>.</returns> /// <remarks>NOTE: Entry names are always relative to <paramref name="compressedArchiveAccess"/>. Path separators will be normalized to forward slash.</remarks> /// <exception cref="ArgumentNullException">Thrown if <paramref name="compressedArchiveAccess"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="locationInArchive"/> is malformed i.e. is not null or empty, or does not end with a directory separator character.</exception> /// <exception cref="FileNotFoundException">Thrown if <paramref name="locationInArchive"/> identifies a nested archive that cannot be located.</exception> public static IEnumerable <ICompressedArchiveEntry> ListEntries(this ICompressedArchiveAccess compressedArchiveAccess, string locationInArchive, bool includeContainers) { return(compressedArchiveAccess.ListEntries(locationInArchive, includeContainers, recurse: false)); }