#pragma once
//---------------------------------------------------------------------------
#include "../KbUnArc.h"
#include "KbGzFile.h"

class KbUnTar : public KbUnArc
{
private:
    struct TarInfo
    {
        KPI_FILEINFO fi;
        UINT64       qwStartOffset;
        wchar_t      pszFileName[1];
    };
    HANDLE      m_hHeap;
    IKpiFile   *m_pFile;
    TarInfo   **m_ppTarInfo;
    DWORD       m_dwCount;
    DWORD       m_dwCapacity;
    BOOL        m_bIsGZ;
    virtual ~KbUnTar(void);
public:
    BOOL WINAPI GetArchiveInfo(const KPI_ARCHIVEINFO **ppArchiveInfo);
    BOOL WINAPI EnumFileInfo(DWORD dwIndex, const KPI_FILEINFO **ppFileInfo);
    BOOL WINAPI Extract(DWORD dwIndex, IKpiFile **ppFile, UINT64 qwSize);

    BOOL   __fastcall Open(IKpiFile *pFile, IKpiFolder *pFolder, const wchar_t *cszOutputPath);
    KbUnTar(UnArcConfig *pConfig);
};
