2012-11-19 11:04:57 +00:00
|
|
|
#pragma once
|
2015-02-28 05:05:57 +00:00
|
|
|
#include <string>
|
2012-10-01 15:32:32 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
#ifdef __cplusplus
|
2022-10-10 00:22:17 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
#endif
|
|
|
|
|
2016-06-05 20:39:51 +00:00
|
|
|
#include "7zip/7z.h"
|
2022-10-10 00:22:17 +00:00
|
|
|
#include "7zip/7zCrc.h"
|
2016-06-05 20:39:51 +00:00
|
|
|
#include "7zip/7zFile.h"
|
|
|
|
#include "7zip/Types.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class C7zip
|
|
|
|
{
|
|
|
|
public:
|
2016-01-04 20:59:16 +00:00
|
|
|
C7zip(const char * FileName);
|
2015-12-23 19:34:47 +00:00
|
|
|
~C7zip();
|
2012-11-19 11:04:57 +00:00
|
|
|
|
2015-12-23 20:04:36 +00:00
|
|
|
typedef void (*LP7ZNOTIFICATION)(const char * Status, void * CBInfo);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
inline int NumFiles(void) const
|
|
|
|
{
|
|
|
|
return m_db ? m_db->db.NumFiles : 0;
|
|
|
|
}
|
|
|
|
inline CSzFileItem * FileItem(int index) const
|
|
|
|
{
|
|
|
|
return m_db ? &m_db->db.Files[index] : nullptr;
|
|
|
|
}
|
|
|
|
inline int FileSize(void) const
|
|
|
|
{
|
|
|
|
return m_FileSize;
|
|
|
|
}
|
|
|
|
inline bool OpenSuccess(void) const
|
|
|
|
{
|
|
|
|
return m_Opened;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetFile(int index, Byte * Data, size_t DataLen);
|
2022-08-01 03:45:52 +00:00
|
|
|
const char * FileName(char * FileName, size_t SizeOfFileName) const;
|
2015-12-23 19:34:47 +00:00
|
|
|
std::wstring FileNameIndex(int index);
|
2012-11-19 11:04:57 +00:00
|
|
|
|
2015-12-23 19:34:47 +00:00
|
|
|
void SetNotificationCallback(LP7ZNOTIFICATION NotfyFnc, void * CBInfo);
|
2012-11-19 11:04:57 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
C7zip(void);
|
2022-10-10 00:22:17 +00:00
|
|
|
C7zip(const C7zip &);
|
|
|
|
C7zip & operator=(const C7zip &);
|
2021-04-13 00:07:11 +00:00
|
|
|
|
|
|
|
CSzArEx * m_db;
|
|
|
|
CFileInStream m_archiveStream;
|
|
|
|
CLookToRead m_archiveLookStream;
|
|
|
|
ISzAlloc m_allocImp;
|
|
|
|
ISzAlloc m_allocTempImp;
|
|
|
|
int m_FileSize;
|
|
|
|
char m_FileName[260];
|
|
|
|
int m_CurrentFile;
|
|
|
|
bool m_Opened;
|
2015-12-23 19:34:47 +00:00
|
|
|
|
2021-04-02 08:14:15 +00:00
|
|
|
// Used for extraction
|
2022-10-10 00:22:17 +00:00
|
|
|
UInt32 m_blockIndex; // It can have any value before first call (if outBuffer = 0)
|
|
|
|
Byte * m_outBuffer; // It must be 0 before first call for each new archive
|
|
|
|
size_t m_outBufferSize; // It can have any value before first call (if outBuffer = 0)
|
2015-12-23 19:34:47 +00:00
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
static void * AllocAllocImp(void * p, size_t size);
|
|
|
|
static void AllocFreeImp(void * p, void * address); // Address can be 0
|
2015-12-23 19:34:47 +00:00
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
static SRes SzFileReadImp(void * object, void * buffer, size_t * processedSize);
|
|
|
|
static SRes SzFileSeekImp(void * p, Int64 * pos, ESzSeek origin);
|
2015-12-23 19:34:47 +00:00
|
|
|
|
|
|
|
//static void __stdcall StatusUpdate(_7Z_STATUS status, int Value1, int Value2, C7zip * _this);
|
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
static void NotfyCallbackDefault(const char * /*Status*/, void * /*CBInfo*/)
|
|
|
|
{
|
|
|
|
}
|
2015-12-23 19:34:47 +00:00
|
|
|
|
|
|
|
LP7ZNOTIFICATION m_NotfyCallback;
|
2021-04-13 00:07:11 +00:00
|
|
|
void * m_NotfyCallbackInfo;
|
2012-10-01 15:32:32 +00:00
|
|
|
};
|