I suppose you could try looking for the pk56 ident by moving back from 
the end of the file to get it's starting point.

I haven't coded anything like this in a while so there could be 
blatantly obvious errors.
Something like this should work:

#define IDENT (('6'<<24)+('5'<<16)+('K'<<8)+'P') //"PK56"

byte *looking_for_the_offset = (btye*)filebuffer + length_of_file;
for( int i = length_of_file; i >= 0; i-- )
{
    if( *(int*)looking_for_the_offset == IDENT )
    {
        //found the start of ZIP_EndOfCentralDirRecord, do whatever
    }
    looking_for_the_offset--;
}

theY4Kman wrote:
> I don't believe you understand my message correctly. The
> ZIP_EndOfCentralDirRecord
> is essentially at the end of the file. One would parse the file by fseek'ing
> to (EOF-sizeof(ZIP_EndOfCentralDirRecord)) and fread'ing in the struct.
> However, since the comment is of variable length, there is no way to
> correctly read in the ZIP_EndOfCentralDirRecord. Thus, there is no way to
> access commentLength.
>
> On Wed, May 14, 2008 at 9:53 PM, Mark Chandler <[EMAIL PROTECTED]> wrote:
>
>   
>> You can work out the size of the comment by commentLength
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of theY4Kman
>> Sent: Thursday, May 15, 2008 8:18 AM
>> To: Discussion of Half-Life Programming
>> Subject: [hlcoders] Pakfile Lump Reading
>>
>> I'm developing a C++ extension for SourceMod which will extract the files
>> stored in the Pakfile lump of a BSP. I read over the page, "The Source
>> Engine BSP File Format <http://www.geocities.com/cofrdrbob/bspformat.html
>>     
>>> ,"
>>>       
>> by Rof and it has helped me a lot. I've been trying to retrieve the list of
>> ZIP_FileHeaders, but I've had some trouble: I don't know how it's possible
>> to get the ZIP_EndOfCentralDirRecord. Rof's page states that this struct is
>> at the end of the Pakfile lump. However, the struct has a variable length
>> comment at the end of it. The only way I can know the size of that comment
>> is to have the ZIP_EndOfCentralDirRecord at hand...You can see my dilemma.
>>
>> struct ZIP_EndOfCentralDirRecord
>> {
>>    DECLARE_BYTESWAP_DATADESC();
>>    unsigned int    signature; // 4 bytes PK56
>>    unsigned short    numberOfThisDisk;  // 2 bytes
>>    unsigned short    numberOfTheDiskWithStartOfCentralDirectory; // 2 bytes
>>    unsigned short    nCentralDirectoryEntries_ThisDisk;    // 2 bytes
>>    unsigned short    nCentralDirectoryEntries_Total;    // 2 bytes
>>    unsigned int    centralDirectorySize; // 4 bytes
>>    unsigned int    startOfCentralDirOffset; // 4 bytes
>>    unsigned short    commentLength; // 2 bytes
>>    // zip file comment follows
>> };
>> _______________________________________________
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>>
>> _______________________________________________
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>>
>>
>>     
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
>   


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to