|
@@ -3,21 +3,54 @@ Namespace std.zipfile
|
|
|
|
|
|
Using miniz
|
|
Using miniz
|
|
|
|
|
|
-#rem monkeydoc @hidden
|
|
|
|
|
|
+#rem monkeydoc The ZipFile class.
|
|
#end
|
|
#end
|
|
Class ZipFile
|
|
Class ZipFile
|
|
|
|
|
|
|
|
+ #rem monkeydoc Array of all files contained in the zip.
|
|
|
|
+ #end
|
|
Property Files:String[]()
|
|
Property Files:String[]()
|
|
Return _files
|
|
Return _files
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ #rem monkeydoc Closes the zip.
|
|
|
|
+ #end
|
|
Method Close()
|
|
Method Close()
|
|
If Not _data Return
|
|
If Not _data Return
|
|
libc.free( _zip )
|
|
libc.free( _zip )
|
|
|
|
+ _files=Null
|
|
|
|
+ _sizes=Null
|
|
_data.Discard()
|
|
_data.Discard()
|
|
_data=Null
|
|
_data=Null
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ #rem monkeydoc Checks if a file is contained in the zip.
|
|
|
|
+ #end
|
|
|
|
+ Method Contains:Bool( file:String )
|
|
|
|
+
|
|
|
|
+ Return FindFile( file )<>-1
|
|
|
|
+ End
|
|
|
|
+
|
|
|
|
+ #rem moneydoc Extracts a file from the zip into a databuffer.
|
|
|
|
+ #end
|
|
|
|
+ Method ExtractData:DataBuffer( file:String )
|
|
|
|
+
|
|
|
|
+ Local i:=FindFile( file )
|
|
|
|
+ If i=-1 Return Null
|
|
|
|
+
|
|
|
|
+ Local size:=_sizes[i]
|
|
|
|
+
|
|
|
|
+ Local buf:=New DataBuffer( size )
|
|
|
|
+
|
|
|
|
+ If mz_zip_reader_extract_to_mem( _zip,i,buf.Data,size,0 ) Return buf
|
|
|
|
+
|
|
|
|
+ buf.Discard()
|
|
|
|
+
|
|
|
|
+ Return Null
|
|
|
|
+ End
|
|
|
|
+
|
|
|
|
+ #rem monkeydoc @hidden
|
|
|
|
+ #end
|
|
Method FindFile:Int( file:String )
|
|
Method FindFile:Int( file:String )
|
|
|
|
|
|
For Local i:=0 Until _files.Length
|
|
For Local i:=0 Until _files.Length
|
|
@@ -27,6 +60,8 @@ Class ZipFile
|
|
Return -1
|
|
Return -1
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ #rem monkeydoc @hidden
|
|
|
|
+ #end
|
|
Method Extract:Bool( dir:String,prefix:String="" )
|
|
Method Extract:Bool( dir:String,prefix:String="" )
|
|
|
|
|
|
If Not dir.EndsWith( "/" ) dir+="/"
|
|
If Not dir.EndsWith( "/" ) dir+="/"
|