Subversion Repositories Kolibri OS

Rev

Rev 5729 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "7z.h"
  4. #include "7zAlloc.h"
  5. #include "7zBuf.h"
  6. #include "7zCrc.h"
  7. #include "7zFile.h"
  8. #include "7zVersion.h"
  9.  
  10. static ISzAlloc g_Alloc = { SzAlloc, SzFree };
  11.  
  12. int test_archive(const char *path)
  13. {
  14.     CFileInStream archiveStream;
  15.     CLookToRead lookStream;
  16.     CSzArEx db;
  17.     SRes res;
  18.     ISzAlloc allocImp;
  19.     ISzAlloc allocTempImp;
  20.     UInt16 *temp = NULL;
  21.  
  22.     allocImp.Alloc = SzAlloc;
  23.     allocImp.Free = SzFree;
  24.  
  25.     allocTempImp.Alloc = SzAllocTemp;
  26.     allocTempImp.Free = SzFreeTemp;
  27.  
  28.     if (InFile_Open(&archiveStream.file, path))
  29.     {
  30.         printf("can not open input file");
  31.         return -1;
  32.     }
  33.  
  34.     FileInStream_CreateVTable(&archiveStream);
  35.     LookToRead_CreateVTable(&lookStream, False);
  36.  
  37.     lookStream.realStream = &archiveStream.s;
  38.     LookToRead_Init(&lookStream);
  39.  
  40.     CrcGenerateTable();
  41.  
  42.     SzArEx_Init(&db);
  43.  
  44.     res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
  45.  
  46.     SzArEx_Free(&db, &allocImp);
  47.     SzFree(NULL, temp);
  48.  
  49.     File_Close(&archiveStream.file);
  50.  
  51.     if (res == SZ_OK)
  52.         return 0;
  53.     else return -1;
  54. };
  55.