'Class module
Sub Class_Globals
Private NameList As List
Private OffsetList As List
Private lengthList As List
Private zipped As RandomAccessFile
Private aDir As String
Private aFileName As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Dir As String, FileName As String)
NameList.Initialize
OffsetList.Initialize
lengthList.Initialize
aDir=Dir
aFileName=FileName
Dim test As Boolean = True
zipped.Initialize(Dir,FileName,True)
Dim a As Long = 0
Dim b As Long = 0
Dim lengthCompressed As Long = 0
Dim lengthUnCompressed As Long = 0
Dim FileNameLength As Int = 0
Dim ExtraFieldLength As Int = 0
Do While (test=True And a < zipped.Size)
Dim buffer(4) As Byte
a = a + 0
zipped.ReadBytes(buffer,0,4,a)
If (buffer(0)=0x50 And buffer(1)=0x4b And buffer(2)=0x03 And buffer(3)=0x04) Then
a = b+18
zipped.ReadBytes(buffer,0,4,a)
lengthCompressed=buffer(3)*16777216+buffer(2)*65536+buffer(1)*256+buffer(0)
a = b+22
zipped.ReadBytes(buffer,0,4,a)
lengthUnCompressed=buffer(3)*16777216+buffer(2)*65536+buffer(1)*256+buffer(0)
a = b+26
zipped.ReadBytes(buffer,0,2,a)
FileNameLength=buffer(1)*256+buffer(0)
a = b+28
zipped.ReadBytes(buffer,0,2,a)
ExtraFieldLength=buffer(1)*256+buffer(0)
Dim buffer(FileNameLength) As Byte
a = b+30
zipped.ReadBytes(buffer,0,FileNameLength,a)
NameList.Add(BytesToString(buffer,0,FileNameLength,"UTF8"))
Log(NameList.Get(NameList.Size-1))
a=b+30+FileNameLength+ExtraFieldLength
Log(NameList.Get(NameList.Size-1)&" ... "&a&" ... "&lengthCompressed)
OffsetList.Add(a)
lengthList.Add(lengthCompressed)
Dim buffer(4) As Byte
a=b+30+FileNameLength+ExtraFieldLength+lengthCompressed
zipped.ReadBytes(buffer,0,4,a)
If (buffer(0)=0x50 And buffer(1)=0x4b And buffer(2)=0x07 And buffer(3)=0x08) Then b=a+4 Else b=a
If (buffer(0)=0x50 And buffer(1)=0x4b And buffer(2)=0x01 And buffer(3)=0x02) Then test=False
Else
test=False
End If
Loop
End Sub
private Sub extractDirName(a As String) As String
If a.LastIndexOf("/")=0 Then Return ""
Return a.SubString2(0,a.LastIndexOf("/"))
End Sub
private Sub extractFileName(a As String) As String
If a.LastIndexOf("/")=0 Then Return a
Return a.SubString(a.LastIndexOf("/")+1)
End Sub
Public Sub extractAll(Dir As String, FileName As String)
Dim a As Long
Dim b As Long
Dim c As Int = 0
Dim cs As CompressedStreams
'For c = 0 To NameList.Size-1
a=OffsetList.Get(c)
b=lengthList.Get(c)
Dim buffer(b) As Byte
zipped.ReadBytes(buffer,0,b,a)
Dim decompressed() As Byte
decompressed=cs.DecompressBytes(buffer,"zlib") <<<<<<<<<<<<<<<------- CRASHES HERE
Dim kk As String =""
For n = 0 To decompressed.Length-1
kk=kk&" "&decompressed(n)
Next
Msgbox(kk,"")
'Next
End Sub
Public Sub extractOne(Dir As String, FileName As String, number As Int)
End Sub