/* 7zIn.c -- 7z Input functions
2010-10-29 : Igor Pavlov : Public domain */
#include <string.h>
#include "7z.h"
#include "7zCrc.h"
#include "CpuArch.h"
Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; }
#define NUM_FOLDER_CODERS_MAX 32
#define NUM_CODER_STREAMS_MAX 32
void SzCoderInfo_Init(CSzCoderInfo *p)
{
Buf_Init(&p->Props);
}
void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc)
{
Buf_Free(&p->Props, alloc);
SzCoderInfo_Init(p);
}
void SzFolder_Init(CSzFolder *p)
{
p->Coders = 0;
p->BindPairs = 0;
p->PackStreams = 0;
p->UnpackSizes = 0;
p->NumCoders = 0;
p->NumBindPairs = 0;
p->NumPackStreams = 0;
p->UnpackCRCDefined = 0;
p->UnpackCRC = 0;
p->NumUnpackStreams = 0;
}
void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc)
{
UInt32 i;
if (p->Coders)
for (i = 0; i < p->NumCoders; i++)
SzCoderInfo_Free(&p->Coders[i], alloc);
IAlloc_Free(alloc, p->Coders);
IAlloc_Free(alloc, p->BindPairs);
IAlloc_Free(alloc, p->PackStreams);
IAlloc_Free(alloc, p->UnpackSizes);
SzFolder_Init(p);
}
UInt32 SzFolder_GetNumOutStreams(CSzFolder *p)
{
UInt32 result = 0;
UInt32 i;
for (i = 0; i < p->NumCoders; i++)
result += p->Coders[i].NumOutStreams;
return result;
}
int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex)
{
UInt32 i;
for (i = 0; i < p->NumBindPairs; i++)
if (p->BindPairs[i].InIndex == inStreamIndex)
return i;
return -1;
}
int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex)
{
UInt32 i;
for (i = 0; i < p->NumBindPairs; i++)
if (p->BindPairs[i].OutIndex == outStreamIndex)
return i;
return -1;
}
UInt64 SzFolder_GetUnpackSize(CSzFolder *p)
{
int i = (int)SzFolder_GetNumOutStreams(p);
if (i == 0)
return 0;
for (i--; i >= 0; i--)
if (SzFolder_FindBindPairForOutStream(p, i) < 0)
return p->UnpackSizes[i];
/* throw 1; */
return 0;
}
void SzFile_Init(CSzFileItem *p)
{
p->HasStream = 1;
p->IsDir = 0;
p->IsAnti = 0;
p->CrcDefined = 0;
p->MTimeDefined = 0;
}
void SzAr_Init(CSzAr *p)
{
p->PackSizes = 0;
p->PackCRCsDefined = 0;
p->PackCRCs = 0;
p->Folders = 0;
p->Files = 0;
p->NumPackStreams = 0;
p->NumFolders = 0;
p->NumFiles = 0;
}
void SzAr_Free(CSzAr *p, ISzAlloc *alloc)
{
UInt32 i;
if (p->Folders)
for (i = 0; i < p->NumFolders; i++)
SzFolder_Free(&p->Folders[i], alloc);
IAlloc_Free(alloc, p->PackSizes);
IAlloc_Free(alloc, p->PackCRCsDefined);
IAlloc_Free(alloc, p->PackCRCs);
IAlloc_Free(alloc, p->Folders);
IAlloc_Free(alloc, p->Files);
SzAr_Init(p);
}
void SzArEx_Init(CSzArEx *p)
{
SzAr_Init(&p->db);
p->FolderStartPackStreamIndex = 0;
p->PackStreamStartPositions = 0;
p->FolderStartFileIndex = 0;
p->FileIndexToFolderIndexMap = 0;
p->FileNameOffsets = 0;
Buf_Init(&p->FileNames);
}
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc)
{
IAlloc_Free(alloc, p->FolderStartPackStreamIndex);
IAlloc_Free(alloc, p->PackStreamStartPositions);
IAlloc_Free(alloc, p->FolderStartFileIndex);
IAlloc_Free(alloc, p->FileIndexToFolderIndexMap);
IAlloc_Free(alloc, p->FileNameOffsets);
Buf_Free(&p->FileNames, alloc);
SzAr_Free(&p->db, alloc);
SzArEx_Init(p);
}
/*
UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
{
return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
}
UInt64 GetFilePackSize(int fileIndex) const
{
int folderIndex = FileIndexToFolderIndexMap[fileIndex];
if (folderIndex >= 0)
{
const CSzFolder &folderInfo = Folders[folderIndex];
if (FolderStartFileIndex[folderIndex] == fileIndex)
return GetFolderFullPackSize(folderIndex);
}
return 0;
}
*/
#define MY_ALLOC(T, p, size, alloc) { if ((size) == 0) p = 0; else \
if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; }
static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc)
{
UInt32 startPos = 0;
UInt64 startPosSize = 0;
UInt32 i;
UInt32 folderIndex = 0;
UInt32 indexInFolder = 0;
MY_ALLOC(UInt32, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc);
for (i = 0; i < p->db.NumFolders; i++)
{
p->FolderStartPackStreamIndex[i] = startPos;
startPos += p->db.Folders[i].NumPackStreams;
}
MY_ALLOC(UInt64, p->PackStreamStartPositions, p->db.NumPackStreams, alloc);
for (i = 0; i < p->db.NumPackStreams; i++)
{
p->PackStreamStartPositions[i] = startPosSize;
startPosSize += p->db.PackSizes[i];
}
MY_ALLOC(UInt32, p->FolderStartFileIndex, p->db.NumFolders, alloc);
MY_ALLOC(UInt32, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc);
for (i = 0; i < p->db.NumFiles; i++)
{
CSzFileItem *file = p->db.Files + i;
int emptyStream = !file->HasStream;
if (emptyStream && indexInFolder == 0)
{
p->FileIndexToFolderIndexMap[i] = (UInt32)-1;
continue;
}
if (indexInFolder == 0)
{
/*
v3.13 incorrectly worked with empty folders
v4.07: Loop for skipping empty folders
*/
for (;;)
{
if (folderIndex >= p->db.NumFolders)
return SZ_ERROR_ARCHIVE;
p->FolderStartFileIndex[folderIndex] = i;
if (p->db.Folders[folderIndex].NumUnpackStreams != 0)
break;
folderIndex++;
}
}
p->FileIndexToFolderIndexMap[i] = folderIndex;
if (emptyStream)
continue;
indexInFolder++;
if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams)
{
folderIndex++;
indexInFolder = 0;
}
}
return SZ_OK;
}
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder)
{
return p->dataPos +
p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder];
}
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize)
{
UInt32 packStreamIndex = p->FolderStartPackStreamIndex[folderIndex];
CSzFolder *folder = p->db.Folders + folderIndex;
UInt64 size = 0;
UInt32 i;
for (i = 0; i < folder->NumPackStreams; i++)
{
UInt64 t = size + p->db.PackSizes[packStreamIndex + i];
if (t < size) /* check it */
return SZ_ERROR_FAIL;
size = t;
}
*resSize = size;
return SZ_OK;
}
/*
SRes SzReadTime(const CObjectVector<CBuf> &dataVector,
CObjectVector<CSzFileItem> &files, UInt64 type)
{
CBoolVector boolVector;
RINOK(ReadBoolVector2(files.Size(), boolVector))
CStreamSwitch streamSwitch;
RINOK(streamSwitch.Set(this, &dataVector));
for (int i = 0; i < files.Size(); i++)
{
CSzFileItem &file = files[i];
CArchiveFileTime fileTime;
bool defined = boolVector[i];
if (defined)
{
UInt32 low, high;
RINOK(SzReadUInt32(low));
RINOK(SzReadUInt32(high));
fileTime.dwLowDateTime = low;
fileTime.dwHighDateTime = high;
}
switch(type)
{
case k7zIdCTime: file.IsCTimeDefined = defined; if (defined) file.CTime = fileTime; break;
case k7zIdATime: file.IsATimeDefined = defined; if (defined) file.ATime = fileTime; break;
case k7zIdMTime: file.IsMTimeDefined = defined; if (defined) file.MTime = fileTime; break;
}
}
return SZ_OK;
}
*/
static int TestSignatureCandidate(Byte *testBytes)
{
size_t i;
for (i = 0; i < k7zSignatureSize; i++)
if (testBytes[i] != k7zSignature[i])
return 0;
return 1;
}
typedef struct _CSzState
{
Byte *Data;
size_t Size;
}CSzData;
static SRes SzReadByte(CSzData *sd, Byte *b)
{
if (sd->Size == 0)
return SZ_ERROR_ARCHIVE;
sd->Size--;
*b = *sd->Data++;
return SZ_OK;
}
static SRes SzReadBytes(CSzData
没有合适的资源?快使用搜索试试~ 我知道了~
lib7z-从内存解压.rar_7z lib_7z.lib_7zlib_lib7z-从内存解压_zip静态库
共101个文件
obj:20个
c:19个
tlog:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 66 浏览量
2022-09-24
21:28:57
上传
评论
收藏 674KB RAR 举报
温馨提示
使用7zlib静态库解压缩文件,VS2010版
资源推荐
资源详情
资源评论
收起资源包目录
lib7z-从内存解压.rar_7z lib_7z.lib_7zlib_lib7z-从内存解压_zip静态库 (101个子文件)
Dec7z.pro.user.2.7pre1 13KB
7zIn.c 39KB
LzmaDec.c 28KB
7zMain.c 18KB
Ppmd7.c 17KB
7zDec.c 13KB
Lzma2Dec.c 10KB
7zFile.c 7KB
Ppmd7Dec.c 5KB
Ppmd7Enc.c 4KB
7zStream.c 4KB
CpuArch.c 3KB
Bcj2.c 3KB
Bra.c 3KB
func.c 3KB
Bra86.c 2KB
7zCrc.c 2KB
7zAlloc.c 1KB
7zCrcOpt.c 957B
7zBuf.c 537B
main.cpp 5KB
7z.exe 151KB
lib_7z.vcxproj.filters 4KB
7z.vcxproj.filters 942B
LzmaDec.h 7KB
Types.h 6KB
7z.h 5KB
CpuArch.h 4KB
Ppmd7.h 4KB
Lzma2Dec.h 2KB
Ppmd.h 2KB
Bra.h 2KB
7zFile.h 2KB
Bcj2.h 745B
7zBuf.h 688B
func.h 640B
7zCrc.h 635B
7zAlloc.h 326B
7zVersion.h 261B
7zMain.h 237B
7z.lastbuildstate 74B
7z.lastbuildstate 71B
7z.lib 878KB
7z.lib 878KB
lib_7z.log 7KB
7z.log 3KB
7z.Build.CppClean.log 2KB
7z.Build.CppClean.log 906B
7z.exe.intermediate.manifest 381B
main.obj 507KB
7zIn.obj 103KB
LzmaDec.obj 78KB
Ppmd7.obj 64KB
7zMain.obj 60KB
7zDec.obj 51KB
Lzma2Dec.obj 46KB
Ppmd7Dec.obj 43KB
Ppmd7Enc.obj 42KB
7zStream.obj 42KB
7zFile.obj 41KB
func.obj 38KB
Bra.obj 38KB
CpuArch.obj 37KB
Bcj2.obj 37KB
Bra86.obj 36KB
7zCrc.obj 35KB
7zCrcOpt.obj 34KB
7zBuf.obj 34KB
7zAlloc.obj 6KB
7z.pdb 1.74MB
vc100.pdb 236KB
vc100.pdb 92KB
Dec7z.pro 893B
7z.sln 1KB
7z.sln 870B
7zcpp.suo 14KB
7z.suo 12KB
7z.suo 12KB
CL.read.1.tlog 241KB
CL.read.1.tlog 21KB
cl.command.1.tlog 12KB
CL.write.1.tlog 7KB
Lib-link.read.1.tlog 4KB
link.read.1.tlog 3KB
lib.command.1.tlog 3KB
Lib-link.write.1.tlog 2KB
link.command.1.tlog 1KB
mt.read.1.tlog 1KB
mt.command.1.tlog 750B
cl.command.1.tlog 610B
mt.write.1.tlog 396B
link.write.1.tlog 388B
CL.write.1.tlog 254B
7z.write.1.tlog 0B
7z.write.1.tlog 0B
Dec7z.pro.user 48KB
jsontest.vcxproj.user 143B
7z.vcxproj.user 143B
lib_7z.vcxproj.user 143B
lib_7z.vcxproj 8KB
共 101 条
- 1
- 2
资源评论
朱moyimi
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功