Код модуля для работы с PAK файлами:
Public Type FileInPAK
named As String * 56
filepos As Long
filelen As Long
End Type
Public Type PAKFileHeader
ident As Long
dirofs As Long
dirlen As Long
End Type
Const MAX_FILES_IN_PACK = 4096
Dim PakHeader As PAKFileHeader
Dim PakFiles(MAX_FILES_IN_PACK) As FileInPAK
Dim NumPakFiles As Integer
Dim PakPath As String * 64
Dim FileToDelete As Boolean
Dim PackedFile As String
Dim FilePAK As String
Dim FileLoaded() As String
Dim PakEnable As Boolean, NBFileInPak
Sub OpenPAKFile(Filename As String)
Dim i As Long
If PakEnable = False Then
On Error GoTo Fin
Open Filename For Binary Lock Read As 80
Get #80, , PakHeader
Seek #80, PakHeader.dirofs + 1
Get #80, , PakFiles()
For i = 0 To 4096
If Len(PakFiles(i).named) < 3 Then Exit For
PakFiles(i).named = Trim(Left(PakFiles(i).named, InStr(PakFiles(i).named, Chr(0)) - 1))
Next i
NBFileInPak = Int(PakHeader.dirlen / Len(PakFiles(1)))
PackedFile = Filename
PakEnable = True
Exit Sub
End If
Fin:
PakEnable = False
End Sub
Sub ClosePAKFile()
If PakEnable = True Then
PakEnable = False
Close 80
End If
End Sub
Sub GetFile(ByRef Filename As String)
Dim FileIndex As Integer
Dim i As Integer
On Error GoTo SendError
If PakEnable = True Then
FileIndex = -1
If Dir(Filename) = "" Then
For i = 0 To NBFileInPak
If UCase(Filename) = Trim(UCase(PakFiles(i).named)) Then FileIndex = i: Exit For
Next i
If FileIndex = -1 Then Filename = "": Exit Sub
With PakFiles(FileIndex)
Filename = Trim(.named)
For i = 1 To Len(Filename)
If Mid(Filename, i, 1) = "/" Then Mid(Filename, i, 1) = "\"
Next i
For i = Len(Filename) To 1 Step -1
If Mid(Filename, i, 1) = "\" Then Exit For
Next i
Filename = Mid(Filename, i + 1)
Open Filename For Binary As 4
ReDim a(.filelen + 1) As Byte
Get #80, .filepos + 1, a
Put #4, , a
Close #4
FileToDelete = True
FilePAK = Filename
End With
End If
End If
Exit Sub
SendError:
Err.Clear
End Sub
Sub DeleteTempFile(File As String)
If File <> "" And PakEnable = True And FileToDelete = True And FilePAK = File Then
FileToDelete = False
Kill File
End If
End Sub
Так вот есть у меня к примеру готовый пак-файл, с деревом папок (text,images...) в папках файлы. Как открыть этот пак и загрузить какой-нибудь текст из папки text в текстбокс? Я понял что надо OpenPakFile и getfile а как далее то??? У кого какие соображения отпишитесь.
Ответить
|