forked from KolibriOS/kolibrios
13638068dc
git-svn-id: svn://kolibrios.org@5728 a494cfbc-eb01-0410-851d-a64ba20cac60
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "7z.h"
|
|
#include "7zAlloc.h"
|
|
#include "7zBuf.h"
|
|
#include "7zCrc.h"
|
|
#include "7zFile.h"
|
|
#include "7zVersion.h"
|
|
|
|
static ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
|
|
|
int test_archive(const char *path)
|
|
{
|
|
CFileInStream archiveStream;
|
|
CLookToRead lookStream;
|
|
CSzArEx db;
|
|
SRes res;
|
|
ISzAlloc allocImp;
|
|
ISzAlloc allocTempImp;
|
|
UInt16 *temp = NULL;
|
|
|
|
allocImp.Alloc = SzAlloc;
|
|
allocImp.Free = SzFree;
|
|
|
|
allocTempImp.Alloc = SzAllocTemp;
|
|
allocTempImp.Free = SzFreeTemp;
|
|
|
|
if (InFile_Open(&archiveStream.file, path))
|
|
{
|
|
printf("can not open input file");
|
|
return -1;
|
|
}
|
|
|
|
FileInStream_CreateVTable(&archiveStream);
|
|
LookToRead_CreateVTable(&lookStream, False);
|
|
|
|
lookStream.realStream = &archiveStream.s;
|
|
LookToRead_Init(&lookStream);
|
|
|
|
CrcGenerateTable();
|
|
|
|
SzArEx_Init(&db);
|
|
|
|
res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
|
|
|
|
SzArEx_Free(&db, &allocImp);
|
|
SzFree(NULL, temp);
|
|
|
|
File_Close(&archiveStream.file);
|
|
|
|
if (res == SZ_OK)
|
|
return 0;
|
|
else return -1;
|
|
};
|