private IList <ArchiveFileInfo> InternalGetFiles(Predicate <string> fileFilter) { using CompressionEngine compressionEngine = CreateCompressionEngine(); ArchiveFileStreamContext archiveFileStreamContext = new ArchiveFileStreamContext(FullName, null, null); archiveFileStreamContext.EnableOffsetOpen = true; IList <ArchiveFileInfo> fileInfo = compressionEngine.GetFileInfo(archiveFileStreamContext, fileFilter); for (int i = 0; i < fileInfo.Count; i = checked (i + 1)) { fileInfo[i].Archive = this; } return(fileInfo); }
/// <summary> /// Uses a CompressionEngine to get ArchiveFileInfo objects from this /// archive, and then associates them with this ArchiveInfo instance. /// </summary> /// <param name="fileFilter">Optional predicate that can determine /// which files to process.</param> /// <returns>A list of <see cref="ArchiveFileInfo"/> objects, each /// containing information about a file in the archive.</returns> private IList <ArchiveFileInfo> InternalGetFiles(Predicate <string> fileFilter) { using (CompressionEngine compressionEngine = this.CreateCompressionEngine()) { ArchiveFileStreamContext streamContext = new ArchiveFileStreamContext(this.FullName, null, null); streamContext.EnableOffsetOpen = true; IList <ArchiveFileInfo> files = compressionEngine.GetFileInfo(streamContext, fileFilter); for (int i = 0; i < files.Count; i++) { files[i].Archive = this; } return(files); } }
public static void TestCompressionEngineNullParams( CompressionEngine engine, ArchiveFileStreamContext streamContext, string[] testFiles) { Exception caughtEx; Console.WriteLine("Testing null streamContext."); caughtEx = null; try { engine.Pack(null, testFiles); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.Pack(null, testFiles, 0); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); Console.WriteLine("Testing null files."); caughtEx = null; try { engine.Pack(streamContext, null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); Console.WriteLine("Testing null files."); caughtEx = null; try { engine.Pack(streamContext, null, 0); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); Console.WriteLine("Testing null stream."); caughtEx = null; try { engine.IsArchive(null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.FindArchiveOffset(null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.GetFiles(null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.GetFileInfo(null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.Unpack(null, "testUnpack.txt"); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); Console.WriteLine("Testing null streamContext."); caughtEx = null; try { engine.GetFiles(null, null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.GetFileInfo(null, null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); caughtEx = null; try { engine.Unpack((IUnpackStreamContext) null, null); } catch (Exception ex) { caughtEx = ex; } Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx); }