-
Notifications
You must be signed in to change notification settings - Fork 0
/
CGUnzipFiles.cls
241 lines (190 loc) · 6.67 KB
/
CGUnzipFiles.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CGUnzipFiles"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'
' UnZip Class
Public Enum ZMessageLevel
All = 0
Less = 1
NoMessages = 2
End Enum
Public Enum ZExtractType
Extract = 0
ListContents = 1
End Enum
Public Enum ZPrivilege
Ignore = 0
ACL = 1
Privileges = 2
End Enum
Private miExtractNewer As Integer ' 1 = Extract Only Newer, Else 0
Private miSpaceUnderScore As Integer ' 1 = Convert Space To Underscore, Else 0
Private miPromptOverwrite As Integer ' 1 = Prompt To Overwrite Required, Else 0
Private miQuiet As ZMessageLevel ' 2 = No Messages, 1 = Less, 0 = All
Private miWriteStdOut As Integer ' 1 = Write To Stdout, Else 0
Private miTestZip As Integer ' 1 = Test Zip File, Else 0
Private miExtractList As ZExtractType ' 0 = Extract, 1 = List Contents
Private miExtractOnlyNewer As Integer ' 1 = Extract Only Newer, Else 0
Private miDisplayComment As Integer ' 1 = Display Zip File Comment, Else 0
Private miHonorDirectories As Integer ' 1 = Honor Directories, Else 0
Private miOverWriteFiles As Integer ' 1 = Overwrite Files, Else 0
Private miConvertCR_CRLF As Integer ' 1 = Convert CR To CRLF, Else 0
Private miVerbose As Integer ' 1 = Zip Info Verbose
Private miCaseSensitivity As Integer ' 1 = Case Insensitivity, 0 = Case Sensitivity
Private miPrivilege As ZPrivilege ' 1 = ACL, 2 = Privileges, Else 0
Private msZipFileName As String ' The Zip File Name
Private msExtractDir As String ' Extraction Directory, Null If Current Directory
Public Property Get ExtractNewer() As Boolean
ExtractNewer = miExtractNewer = 1
End Property
Public Property Let ExtractNewer(ByVal bExtractNewer As Boolean)
miExtractNewer = IIf(bExtractNewer, 1, 0)
End Property
Public Property Get SpaceToUnderScore() As Boolean
SpaceToUnderScore = miSpaceUnderScore = 1
End Property
Public Property Let SpaceToUnderScore(ByVal bConvert As Boolean)
miSpaceUnderScore = IIf(bConvert, 1, 0)
End Property
Public Property Get PromptOverwrite() As Boolean
PromptOverwrite = miPromptOverwrite = 1
End Property
Public Property Let PromptOverwrite(ByVal bPrompt As Boolean)
miPromptOverwrite = IIf(bPrompt, 1, 0)
End Property
Public Property Get MessageLevel() As ZMessageLevel
MessageLevel = miQuiet
End Property
Public Property Let MessageLevel(ByVal iLevel As ZMessageLevel)
miQuiet = iLevel
End Property
Public Property Get WriteToStdOut() As Boolean
WriteToStdOut = miWriteStdOut = 1
End Property
Public Property Let WriteToStdOut(ByVal bWrite As Boolean)
miWriteStdOut = IIf(bWrite, 1, 0)
End Property
Public Property Get TestZip() As Boolean
TestZip = miTestZip = 1
End Property
Public Property Let TestZip(ByVal bTest As Boolean)
miTestZip = IIf(bTest, 1, 0)
End Property
Public Property Get ExtractList() As ZExtractType
ExtractList = miExtractList
End Property
Public Property Let ExtractList(ByVal zExType As ZExtractType)
miExtractList = zExType
End Property
Public Property Get ExtractOnlyNewer() As Boolean
ExtractOnlyNewer = miExtractOnlyNewer = 1
End Property
Public Property Let ExtractOnlyNewer(ByVal bOnlyNewer As Boolean)
miExtractOnlyNewer = IIf(bOnlyNewer, 1, 0)
End Property
Public Property Get DisplayComment() As Boolean
DisplayComment = miDisplayComment = 1
End Property
Public Property Let DisplayComment(ByVal bDisplay As Boolean)
miDisplayComment = IIf(bDisplay, 1, 0)
End Property
Public Property Get HonorDirectories() As Boolean
HonorDirectories = miHonorDirectories = 1
End Property
Public Property Let HonorDirectories(ByVal bHonor As Boolean)
miHonorDirectories = IIf(bHonor, 1, 0)
End Property
Public Property Get OverWriteFiles() As Boolean
OverWriteFiles = miOverWriteFiles = 1
End Property
Public Property Let OverWriteFiles(ByVal bOverWrite As Boolean)
miOverWriteFiles = IIf(bOverWrite, 1, 0)
End Property
Public Property Get ConvertCRtoCRLF() As Boolean
ConvertCRtoCRLF = miConvertCR_CRLF = 1
End Property
Public Property Let ConvertCRtoCRLF(ByVal bConvert As Boolean)
miConvertCR_CRLF = IIf(bConvert, 1, 0)
End Property
Public Property Get Verbose() As Boolean
Verbose = miVerbose = 1
End Property
Public Property Let Verbose(ByVal bVerbose As Boolean)
miVerbose = IIf(bVerbose, 1, 0)
End Property
Public Property Get CaseSensitive() As Boolean
CaseSensitive = miCaseSensitivity = 1
End Property
Public Property Let CaseSensitive(ByVal bCaseSensitive As Boolean)
miCaseSensitivity = IIf(bCaseSensitive, 1, 0)
End Property
Public Property Get Privilege() As ZPrivilege
Privilege = miPrivilege
End Property
Public Property Let Privilege(ByVal zPriv As ZPrivilege)
miPrivilege = zPriv
End Property
Public Property Get ZipFileName() As String
ZipFileName = msZipFileName
End Property
Public Property Let ZipFileName(ByVal sZipFileName As String)
msZipFileName = sZipFileName
End Property
Public Property Get ExtractDir() As String
ExtractDir = msExtractDir
End Property
Public Property Let ExtractDir(ByVal sExtractDir As String)
msExtractDir = sExtractDir
End Property
Public Function Unzip(Optional sZipFileName As String, _
Optional sExtractDir As String) As Long
On Error GoTo vbErrorHandler
Dim lRet As Long
If Len(sZipFileName) > 0 Then
msZipFileName = sZipFileName
End If
If Len(sExtractDir) > 0 Then
msExtractDir = sExtractDir
End If
lRet = VBUnzip(msZipFileName, msExtractDir, miExtractNewer, _
miSpaceUnderScore, miPromptOverwrite, CInt(miQuiet), _
miWriteStdOut, miTestZip, CInt(miExtractList), _
miExtractOnlyNewer, miDisplayComment, miHonorDirectories, _
miOverWriteFiles, miConvertCR_CRLF, miVerbose, _
miCaseSensitivity, CInt(miPrivilege))
Unzip = lRet
Exit Function
vbErrorHandler:
Err.Raise Err.Number, "CGUnZipFiles::Unzip", Err.Description
End Function
Private Sub Class_Initialize()
miExtractNewer = 0
miSpaceUnderScore = 0
miPromptOverwrite = 0
miQuiet = NoMessages
miWriteStdOut = 0
miTestZip = 0
miExtractList = Extract
miExtractOnlyNewer = 0
miDisplayComment = 0
miHonorDirectories = 1
miOverWriteFiles = 1
miConvertCR_CRLF = 0
miVerbose = 0
miCaseSensitivity = 1
miPrivilege = Ignore
End Sub
Public Function GetLastMessage() As String
GetLastMessage = msOutput
End Function