diff options
Diffstat (limited to 'src/WixToolset.Core/Cab/WixEnumerateCab.cs')
-rw-r--r-- | src/WixToolset.Core/Cab/WixEnumerateCab.cs | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/WixToolset.Core/Cab/WixEnumerateCab.cs b/src/WixToolset.Core/Cab/WixEnumerateCab.cs deleted file mode 100644 index 0b4055d6..00000000 --- a/src/WixToolset.Core/Cab/WixEnumerateCab.cs +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
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 | |||
3 | namespace WixToolset.Core.Cab | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using WixToolset.Core.Native; | ||
8 | using Handle = System.Int32; | ||
9 | |||
10 | /// <summary> | ||
11 | /// Wrapper class around interop with wixcab.dll to enumerate files from a cabinet. | ||
12 | /// </summary> | ||
13 | public sealed class WixEnumerateCab : IDisposable | ||
14 | { | ||
15 | private bool disposed; | ||
16 | private List<CabinetFileInfo> fileInfoList; | ||
17 | private CabInterop.PFNNOTIFY pfnNotify; | ||
18 | |||
19 | /// <summary> | ||
20 | /// Creates a cabinet enumerator. | ||
21 | /// </summary> | ||
22 | public WixEnumerateCab() | ||
23 | { | ||
24 | this.pfnNotify = new CabInterop.PFNNOTIFY(this.Notify); | ||
25 | NativeMethods.EnumerateCabBegin(); | ||
26 | } | ||
27 | |||
28 | /// <summary> | ||
29 | /// Destructor for cabinet enumeration. | ||
30 | /// </summary> | ||
31 | ~WixEnumerateCab() | ||
32 | { | ||
33 | this.Dispose(); | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// Enumerates all files in a cabinet. | ||
38 | /// </summary> | ||
39 | /// <param name="cabinetFile">path to cabinet</param> | ||
40 | /// <returns>list of CabinetFileInfo</returns> | ||
41 | public List<CabinetFileInfo> Enumerate(string cabinetFile) | ||
42 | { | ||
43 | this.fileInfoList = new List<CabinetFileInfo>(); | ||
44 | |||
45 | // the callback (this.Notify) will populate the list for each file in cabinet | ||
46 | NativeMethods.EnumerateCab(cabinetFile, this.pfnNotify); | ||
47 | |||
48 | return this.fileInfoList; | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Disposes the managed and unmanaged objects in this object. | ||
53 | /// </summary> | ||
54 | public void Dispose() | ||
55 | { | ||
56 | if (!this.disposed) | ||
57 | { | ||
58 | NativeMethods.EnumerateCabFinish(); | ||
59 | |||
60 | GC.SuppressFinalize(this); | ||
61 | this.disposed = true; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Delegate that's called for every file in cabinet. | ||
67 | /// </summary> | ||
68 | /// <param name="fdint">NOTIFICATIONTYPE</param> | ||
69 | /// <param name="pfdin">NOTIFICATION</param> | ||
70 | /// <returns>System.Int32</returns> | ||
71 | internal Handle Notify(CabInterop.NOTIFICATIONTYPE fdint, CabInterop.NOTIFICATION pfdin) | ||
72 | { | ||
73 | // This is FDI's way of notifying us of how many files total are in the cab, accurate even | ||
74 | // if the files are split into multiple folders - use it to allocate the precise size we need | ||
75 | if (CabInterop.NOTIFICATIONTYPE.ENUMERATE == fdint && 0 == this.fileInfoList.Count) | ||
76 | { | ||
77 | this.fileInfoList.Capacity = pfdin.Folder; | ||
78 | } | ||
79 | |||
80 | if (fdint == CabInterop.NOTIFICATIONTYPE.COPY_FILE) | ||
81 | { | ||
82 | CabinetFileInfo fileInfo = new CabinetFileInfo(pfdin.Psz1, pfdin.Date, pfdin.Time, pfdin.Cb); | ||
83 | this.fileInfoList.Add(fileInfo); | ||
84 | } | ||
85 | |||
86 | return 0; // tell cabinet api to skip this file. | ||
87 | } | ||
88 | } | ||
89 | } | ||