From: ShadowFlare Date: Tue, 5 Jan 2010 07:26:52 +0000 (-0700) Subject: Fix code to allow 2 - 4 GB archives. X-Git-Url: https://sfsrealm.hopto.org/projects/gitweb.cgi?a=commitdiff_plain;h=1859bb9b3bdd30b6aa93f76d0a9848f63c0cf874;p=WinMPQ.git Fix code to allow 2 - 4 GB archives. --- diff --git a/MpqStuff.bas b/MpqStuff.bas index 93586f3..a3ec874 100644 --- a/MpqStuff.bas +++ b/MpqStuff.bas @@ -1136,46 +1136,25 @@ If Mid(OldPath, 2, 1) = ":" Then ChDrive Left(OldPath, 1) ChDir OldPath End Sub Function FindMpqHeader(MpqFile As String) As Long + FindMpqHeader = -1 If FileExists(MpqFile) = False Then - FindMpqHeader = -1 Exit Function End If - Dim hFile - hFile = FreeFile - Open MpqFile For Binary As #hFile - Dim FileLen As Long - FileLen = LOF(hFile) - Dim pbuf As String - pbuf = String(32, Chr(0)) - Dim i As Long - For i = 0 To FileLen - 1 Step 512 - Get #hFile, 1 + i, pbuf - If Left(pbuf, 4) = "MPQ" + Chr(26) Or Left(pbuf, 4) = "BN3" + Chr(26) Then - ' Storm no longer does this, so this shouldn't either - 'FileLen = FileLen - i - 'If JBytes(pbuf, 9, 4) = FileLen - ' FileMpqHeader = i - ' Close #hFile - ' Exit Function - 'Else - ' FileLen = FileLen + i - 'End If - FindMpqHeader = i - Close #hFile - Exit Function - End If - Next i - FindMpqHeader = -1 - Close #hFile + Dim hMPQ As Long, hFile As Long + If SFileOpenArchive(MpqFile, 0, 0, hMPQ) Then + CopyMemory hFile, ByVal hMPQ + 268, 4 + FindMpqHeader = SFileFindMpqHeader(hFile) + SFileCloseArchive hMPQ + End If End Function Function GetNumMpqFiles(MpqFile As String) As Long -Dim fNum As Long, Text As String, MpqHeader As Long -fNum = FreeFile -Text = String(4, Chr(0)) -MpqHeader = FindMpqHeader(MpqFile) -If MpqHeader > -1 Then - Open MpqFile For Binary As #fNum - Get #fNum, MpqHeader + 29, GetNumMpqFiles - Close #fNum -End If + GetNumMpqFiles = 0 + If FileExists(MpqFile) = False Then + Exit Function + End If + Dim hMPQ As Long + If SFileOpenArchive(MpqFile, 0, 0, hMPQ) Then + GetNumMpqFiles = SFileGetFileInfo(hMPQ, SFILE_INFO_NUM_FILES) + SFileCloseArchive hMPQ + End If End Function diff --git a/WinMPQ.vbp b/WinMPQ.vbp index 1a81ae0..3b62fbf 100644 --- a/WinMPQ.vbp +++ b/WinMPQ.vbp @@ -27,11 +27,11 @@ HelpContextID="0" StartMode=0 VersionCompatible32="0" MajorVer=1 -MinorVer=65 +MinorVer=66 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="ShadowFlare Software" VersionFileDescription="ShadowFlare MPQ Archiver" -VersionLegalCopyright="Copyright © ShadowFlare Software 2001-2009" +VersionLegalCopyright="Copyright © ShadowFlare Software 2001-2010" VersionProductName="WinMPQ"