Exemple #1
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// this function will take an achive file name as a parameter
// creates a file information data base so we can read enough content to create files
void processExtraction(char *archFile){
int i; // for loop counter
unsigned char nFiles; // holds number of files

char *temp; // temp character pointer
unsigned int sizeFile; // holds size of file

if((xArchiveFileP=fopen(archFile, "r") )==NULL){ // if open fails
printf("Error opening file \n"); // print an error
exit(1); // exit the prog
}

fread(&nFiles,1,1,xArchiveFileP); // read the size of file

numberFiles = nFiles; // copy the number to temp

for(i = 0; i < numberFiles; i++){ // num for number of files times

fread(&nFiles,1,1,xArchiveFileP); // read the size of file name


temp = malloc(nFiles); // malloc space for file name

fread(temp, nFiles, 1,xArchiveFileP); // read the file name



fread(&sizeFile, 4, 1,xArchiveFileP); // read the size of file


addFileInfo(nFiles, temp, sizeFile); // process info to be added onto struct array

}

}       
Exemple #2
0
BOOL DBI1::reloadFileInfo(PB pb)
{
    if (*((IMOD*&)pb)++ != imodMac)
        return FALSE;

    USHORT  cRefs       = *((USHORT*&)pb)++;
    USHORT* mpimodiref  = (USHORT*)pb;
    USHORT* mpimodcref  = (USHORT*)((PB)mpimodiref    + sizeof(USHORT)*imodMac);
    ICH*  mpirefichFile = (ICH*)   ((PB)mpimodcref    + sizeof(USHORT)*imodMac);
    PCH   rgchNames     = (PCH)    ((PB)mpirefichFile + sizeof(ICH)*cRefs);

    for (IMOD imod = 0; imod < imodMac; imod++) {
        if (!initFileInfo(imod, mpimodcref[imod]))
            return FALSE;
        for (IFILE ifile = 0; ifile < mpimodcref[imod]; ifile++)    {
            UINT iref = mpimodiref[imod] + ifile;
            ICH ich = mpirefichFile[iref];
            if (!addFileInfo(imod, ifile, &rgchNames[ich]))
                return FALSE;
        }
    }
    return TRUE;
}