#include <stdio.h>
#include <dos.h>
#include <malloc.h>
typedef struct{
        char fn[0x40-8];
        long pos,len;
        }ENTRY;

ENTRY entrys[200];
long num_entrys;

make_path(char *p)
{
char *t;
char temp[0x40];

        sprintf(temp,"%s",p);
        t=&temp[0];
        while(*t)
                {
                if(*t=='/')
                        {
                        *t=0;
                        mkdir(temp);
                        *t='/';
                        }
                t++;
                }
}

main()
{
FILE *f;
FILE *fo;
long pos,len,dummy;
long i;
char *temp;

        f=fopen("id1.pak","rb");
        fread(&dummy,sizeof(long),1,f);
        fread(&pos,sizeof(long),1,f);
        fread(&len,sizeof(long),1,f);
        fseek(f,pos,SEEK_SET);
        for(i=0;i<len/0x40;i++)
                fread(&entrys[i],sizeof(ENTRY),1,f);

        for(i=0;i<len/0x40;i++)
                {
                
printf("%x:%x:%s\n",entrys[i].pos,entrys[i].len,entrys[i].fn);
                make_path(entrys[i].fn);
                fo=fopen(entrys[i].fn,"wb");
                fseek(f,entrys[i].pos,SEEK_SET);
                temp = malloc(entrys[i].len);
                fread(temp,sizeof(char),entrys[i].len,f);
                fwrite(temp,sizeof(char),entrys[i].len,fo);
                free(temp);
                fclose(fo);
                }
        fclose(f);

}




