-
Notifications
You must be signed in to change notification settings - Fork 71
/
minizip.ahk
277 lines (206 loc) · 11.2 KB
/
minizip.ahk
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*________________________________________________________________________________________
__ __ _____ _ _ _____ ___________ _____ _____ _ _
| \/ |_ _| \ | |_ _|___ /_ _| __ \ | __ \| | | |
| \ / | | | | \| | | | / / | | | |__) | | | | | | | |
| |\/| | | | | . ` | | | / / | | | ___/ | | | | | | |
| | | |_| |_| |\ |_| |_ / /__ _| |_| | _ | |__| | |____| |____
|_| |_|_____|_| \_|_____/_____|_____|_| (_) |_____/|______|______|
http://edel.realsource.de/downloads/doc_download/27-minizip-dll
Script : MiniZIP.ahk - AutoHotkey Wrapper for minizip.dll
Created On : 27-Jun-2012 / Last Modified: 27-Jun-2012 / v1.0
Author : SKAN ( A.N.Suresh Kumar, [email protected] )
Forum Topic : www.autohotkey.com/community/viewtopic.php?t=88218
My License : Unrestricted! www.autohotkey.com/community/viewtopic.php?p=505843#p505843
_________________________________________________________________________________________
The DLL exported functions names are confusing, atleast for me!.
Here follows the list of wrapper functions, categorically named
and arranged in order of importance:
_______________________________________________________________
Initialization Functions:
01) MiniZIP_Init() <-- Kernel32\LoadLibrary()
02) MZ_SetPassword() <-- ZIP_SetPassword()
Creating/Updating ZIP files:
03) MZ_ZipCreate() <-- ZIP_FileCreate()
04) MZ_ZipOpen() <-- ZIP_FileOpen()
05) MZ_ZipAddFolder() <-- ZIP_DirAdd()
06) MZ_ZipAddFile() <-- ZIP_FileAdd()
07) MZ_ZipAddMem() <-- ZIP_MemAdd()
08) MZ_ZipClose() <-- ZIP_FileClose()
Unzipping ZIP files:
09) MZ_ZipIsValid() <-- ZIP_IsZipArchive()
10) MZ_ZipGetFileCount() <-- ZIP_GetFilesCount()
11) MZ_ZipGetFileNumber() <-- ZIP_GetFileNumber()
12) MZ_ZipIsPasswordRequired() <-- ZIP_IsPasswordRequired()
13) MZ_ZipGetFilename() <-- ZIP_GetFileInfo()
14) MZ_ZipGetComment() <-- ZIP_GetFileComment()
15) MZ_UnzipAll() <-- ZIP_ExtractArchiv()
16) MZ_UnzipFileToDisk() <-- ZIP_ExtractFile()
17) MZ_UnzipFileToMem() <-- ZIP_CatchFile()
Zip/Unzip for MEMORY VARIABLE
18) MZ_MemPack() <-- ZIP_PackMemory()
19) MZ_MemUnpack() <-- ZIP_UnpackMemory()
Compression Parameter
_____________________
MiniZIP handles 4 levels of Compression. When function expects Compression as parameter,
pass one of the following Constant value:
NO_COMPRESSION = 0 / BEST_SPEED = 1 / BEST_COMPRESSION = 9 / DEFAULT_COMPRESSION = -1
Callback Parameter
_____________________
Zip/Unzip functions offer callback facility to AHK functions for which you may pass the
address returned by
RegisterCallback( "ZIP_ArchivCallback" )
OR
RegisterCallback( "ZIP_PackerCallback" )
Callback procedure for MZ_UnzipAll()
MZ_ZipAddFolder()
ZIP_ArchivCallback( Progress, Files ) {
Return 0 ; ZIP_OK = 0 or ZIP_CANCEL = 1
}
Callback procedure for MZ_ZipAddFile()
MZ_ZipAddMem()
MZ_UnzipFileToMem()
MZ_UnzipFileToDisk()
ZIP_PackerCallback( Progress ) {
Return 0 ; ZIP_OK = 0 or ZIP_CANCEL = 1
}
__________________________________________________________________________________________
*/
MiniZIP_Init( DllFile ) { ; MiniZIP_Init()
Return DllCall( "LoadLibrary", Str,DllFile, UInt )
}
MZ_SetPassword( Password="" ) { ; MZ_SetPassword()
Return DllCall( "MiniZIP\ZIP_SetPassword"
, ( A_IsUnicode ? "AStr" : "Str" ), Password
, UInt )
}
MZ_ZipCreate( zipFilename ) { ; MZ_ZipCreate()
Return DllCall( "MiniZIP\ZIP_FileCreate"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFileName, UInt )
}
MZ_ZipOpen( zipFilename ) { ; MZ_ZipOpen()
IfNotExist, %zipfileName%, Return
Return DllCall( "MiniZIP\ZIP_FileOpen"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, UInt )
}
MZ_ZipAddFolder( zipHandle, SourceDir, Compression=-1 ; MZ_ZipAddFolder()
, Callback=0 ) {
Return DllCall( "MiniZIP\ZIP_DirAdd"
, UInt, zipHandle
, ( A_IsUnicode ? "AStr" : "Str" ), SourceDir
, Int , Compression
, UInt, Callback
, UInt )
}
MZ_ZipAddFile( zipHandle, SourceFilename, ArchiveFilename ; MZ_ZipAddFile()
, Compression=-1, Callback=0 ) {
Return DllCall( "MiniZIP\ZIP_FileAdd"
, UInt, zipHandle
, ( A_IsUnicode ? "AStr" : "Str" ), SourceFilename
, ( A_IsUnicode ? "AStr" : "Str" ), ArchiveFilename
, Int , Compression
, UInt, Callback
, UInt )
}
MZ_ZipAddMem( zipHandle, memPointer, memSize, ArchiveFilename ; MZ_ZipAddMem()
, Compression=-1, Callback=0 ) {
Return DllCall( "MiniZIP\ZIP_MemAdd"
, UInt, zipHandle
, UInt, memPointer
, UInt, memSize
, ( A_IsUnicode ? "AStr" : "Str" ), ArchiveFilename
, Int , Compression
, UInt, Callback
, UInt )
}
MZ_ZipClose( zipHandle, Comment="Created with MiniZIP.dll" ) { ; MZ_ZipClose()
Return DllCall( "MiniZIP\ZIP_FileClose"
, UInt, ZipHandle
, ( A_IsUnicode ? "AStr" : "Str" ), Comment
, UInt )
}
MZ_ZipIsValid( zipFilename ) { ; MZ_ZipIsValid(()
IfNotExist, %zipfileName%, Return 3
Return DllCall( "MiniZIP\ZIP_IsZipArchive"
, ( A_IsUnicode ? "AStr" : "Str" ), ZipFilename, UInt )
} ; Return Values: 0 = OK, 1 = NOT_ARCHIVE, 2 = ERROR_IN_ARCHIVE, 3 = FILE_NOT_FOUND
MZ_ZipGetFileCount( zipFilename ) { ; MZ_ZipGetFileCount()
IfNotExist, %zipfileName%, Return
Return DllCall( "MiniZIP\ZIP_GetFilesCount"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, UInt )
}
MZ_ZipGetFileNumber( zipFileName, ArchiveFilename ) { ; MZ_ZipGetFileNumber()
IfNotExist, %zipfileName%, Return
Return DllCall( "MiniZIP\ZIP_GetFileNumber"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, ( A_IsUnicode ? "AStr" : "Str" ), ArchiveFilename
, UInt )
}
MZ_ZipIsPasswordRequired( zipFilename, zipFileNumber ) { ; MZ_ZipIsPasswordRequired()
IfNotExist, %zipfileName%, Return
Return DllCall( "MiniZIP\ZIP_IsPasswordRequired"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, UInt, zipFileNumber, UInt )
}
MZ_ZipGetFilename( zipFilename, zipFileNumber=1 ; MZ_ZipGetFilename()
, ByRef FILEINFO="" ) {
IfNotExist, %zipfileName%, Return
VarSetCapacity( FILEINFO, 310, 0 )
Return DllCall( "MiniZIP\ZIP_GetFileInfo"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, UInt, zipFileNumber
, UInt, &FILEINFO
, ( A_IsUnicode ? "AStr" : "Str" ) )
}
MZ_ZipGetComment( zipFilename ) { ; MZ_ZipGetComment()
IfNotExist, %zipfileName%, Return
Return DllCall( "MiniZIP\ZIP_GetFileComment"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, ( A_IsUnicode ? "AStr" : "Str" ) )
}
MZ_UnzipAll( zipFilename, TargetPath, CreateTargetPath=1 ; MZ_UnzipAll()
, Callback=0 ) {
IfNotExist, %zipfileName%, Return
Return DllCall("MiniZIP\ZIP_ExtractArchiv"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, ( A_IsUnicode ? "AStr" : "Str" ), TargetPath
, UInt, CreateTargetPath
, UInt, Callback
, UInt )
}
MZ_UnzipFileToDisk( zipFilename, zipFileNumber, TargetPath ; MZ_UnzipFileToDisk()
, CreateTargetPath=1, Callback=0 ) {
IfNotExist, %zipfileName%, Return
Return DllCall("MiniZIP\ZIP_ExtractFile"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, UInt, zipFileNumber
, ( A_IsUnicode ? "AStr" : "Str" ), TargetPath
, UInt, CreateTargetPath
, UInt, Callback
, UInt )
}
MZ_UnzipFileToMem( zipFilename, zipFileNumber=1 ; MZ_UnzipFileToMem()
, Callback=0 ) {
IfNotExist, %zipfileName%, Return ErrorLevel := 0
Return hGlobal := DllCall( "MiniZIP\ZIP_CatchFile"
, ( A_IsUnicode ? "AStr" : "Str" ), zipFilename
, UInt, zipFileNumber
, UInt )
, ErrorLevel := DllCall( "GlobalSize", UInt,hGlobal, UInt )
}
MZ_MemPack( memPointer, memSize, Compression=9 ) { ; MZ_MemPack()
Return hGlobal := DllCall( "MiniZIP\ZIP_PackMemory"
, UInt, memPointer
, UInt, memSize
, Int , Compression
, UInt )
, ErrorLevel := DllCall( "GlobalSize", UInt,hGlobal, UInt )
}
MZ_MemUnpack( memPointerSource, memPointerTarget ) { ; MZ_MemUnpack()
Return DllCall( "MiniZIP\ZIP_UnpackMemory"
, UInt, memPointerSource
, UInt, memPointerTarget
, UInt )
}
;____________________________________________________________ // End of MiniZIP.ahk //