aboutsummaryrefslogtreecommitdiff
path: root/src/dtf/WixToolset.Dtf.Compression.Zip/ZipInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/dtf/WixToolset.Dtf.Compression.Zip/ZipInfo.cs82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/dtf/WixToolset.Dtf.Compression.Zip/ZipInfo.cs b/src/dtf/WixToolset.Dtf.Compression.Zip/ZipInfo.cs
new file mode 100644
index 00000000..73f65fa0
--- /dev/null
+++ b/src/dtf/WixToolset.Dtf.Compression.Zip/ZipInfo.cs
@@ -0,0 +1,82 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Dtf.Compression.Zip
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Runtime.Serialization;
8
9 /// <summary>
10 /// Object representing a zip file on disk; provides access to
11 /// file-based operations on the zip file.
12 /// </summary>
13 /// <remarks>
14 /// Generally, the methods on this class are much easier to use than the
15 /// stream-based interfaces provided by the <see cref="ZipEngine"/> class.
16 /// </remarks>
17 [Serializable]
18 public class ZipInfo : ArchiveInfo
19 {
20 /// <summary>
21 /// Creates a new CabinetInfo object representing a zip file in a specified path.
22 /// </summary>
23 /// <param name="path">The path to the zip file. When creating a zip file, this file does not
24 /// necessarily exist yet.</param>
25 public ZipInfo(string path)
26 : base(path)
27 {
28 }
29
30 /// <summary>
31 /// Initializes a new instance of the CabinetInfo class with serialized data.
32 /// </summary>
33 /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
34 /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
35 protected ZipInfo(SerializationInfo info, StreamingContext context)
36 : base(info, context)
37 {
38 }
39
40 /// <summary>
41 /// Creates a compression engine that does the low-level work for
42 /// this object.
43 /// </summary>
44 /// <returns>A new <see cref="ZipEngine"/> instance.</returns>
45 /// <remarks>
46 /// Each instance will be <see cref="CompressionEngine.Dispose()"/>d
47 /// immediately after use.
48 /// </remarks>
49 protected override CompressionEngine CreateCompressionEngine()
50 {
51 return new ZipEngine();
52 }
53
54 /// <summary>
55 /// Gets information about the files contained in the archive.
56 /// </summary>
57 /// <returns>A list of <see cref="ZipFileInfo"/> objects, each
58 /// containing information about a file in the archive.</returns>
59 public new IList<ZipFileInfo> GetFiles()
60 {
61 IList<ArchiveFileInfo> files = base.GetFiles();
62 List<ZipFileInfo> zipFiles = new List<ZipFileInfo>(files.Count);
63 foreach (ZipFileInfo zipFile in files) zipFiles.Add(zipFile);
64 return zipFiles.AsReadOnly();
65 }
66
67 /// <summary>
68 /// Gets information about the certain files contained in the archive file.
69 /// </summary>
70 /// <param name="searchPattern">The search string, such as
71 /// &quot;*.txt&quot;.</param>
72 /// <returns>A list of <see cref="ZipFileInfo"/> objects, each containing
73 /// information about a file in the archive.</returns>
74 public new IList<ZipFileInfo> GetFiles(string searchPattern)
75 {
76 IList<ArchiveFileInfo> files = base.GetFiles(searchPattern);
77 List<ZipFileInfo> zipFiles = new List<ZipFileInfo>(files.Count);
78 foreach (ZipFileInfo zipFile in files) zipFiles.Add(zipFile);
79 return zipFiles.AsReadOnly();
80 }
81 }
82}