This commit is contained in:
parent
d7c987f63b
commit
10989d232a
|
@ -0,0 +1,237 @@
|
|||
7z ANSI-C Decoder 4.48
|
||||
----------------------
|
||||
|
||||
7z ANSI-C Decoder 4.48 Copyright (C) 1999-2006 Igor Pavlov
|
||||
|
||||
7z ANSI-C provides 7z/LZMA decoding.
|
||||
7z ANSI-C version is simplified version ported from C++ code.
|
||||
|
||||
LZMA is default and general compression method of 7z format
|
||||
in 7-Zip compression program (www.7-zip.org). LZMA provides high
|
||||
compression ratio and very fast decompression.
|
||||
|
||||
|
||||
LICENSE
|
||||
-------
|
||||
|
||||
Read lzma.txt for information about license.
|
||||
|
||||
|
||||
Files
|
||||
---------------------
|
||||
|
||||
7zAlloc.* - Allocate and Free
|
||||
7zBuffer.* - Buffer structure
|
||||
7zCrc.* - CRC32 code
|
||||
7zDecode.* - Low level memory->memory decoding
|
||||
7zExtract.* - High level stream->memory decoding
|
||||
7zHeader.* - .7z format constants
|
||||
7zIn.* - .7z archive opening
|
||||
7zItem.* - .7z structures
|
||||
7zMain.c - Test application
|
||||
7zMethodID.* - MethodID structure
|
||||
7zTypes.h - Base types and constants
|
||||
|
||||
|
||||
How To Use
|
||||
----------
|
||||
|
||||
You must download 7-Zip program from www.7-zip.org.
|
||||
|
||||
You can create .7z archive with 7z.exe or 7za.exe:
|
||||
|
||||
7za.exe a archive.7z *.htm -r -mx -m0fb=255
|
||||
|
||||
If you have big number of files in archive, and you need fast extracting,
|
||||
you can use partly-solid archives:
|
||||
|
||||
7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K
|
||||
|
||||
In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only
|
||||
512KB for extracting one file from such archive.
|
||||
|
||||
|
||||
Limitations of current version of 7z ANSI-C Decoder
|
||||
---------------------------------------------------
|
||||
|
||||
- It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.
|
||||
- It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.
|
||||
- It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
|
||||
|
||||
These limitations will be fixed in future versions.
|
||||
|
||||
|
||||
Using 7z ANSI-C Decoder Test application:
|
||||
-----------------------------------------
|
||||
|
||||
Usage: 7zDec <command> <archive_name>
|
||||
|
||||
<Command>:
|
||||
e: Extract files from archive
|
||||
l: List contents of archive
|
||||
t: Test integrity of archive
|
||||
|
||||
Example:
|
||||
|
||||
7zDec l archive.7z
|
||||
|
||||
lists contents of archive.7z
|
||||
|
||||
7zDec e archive.7z
|
||||
|
||||
extracts files from archive.7z to current folder.
|
||||
|
||||
|
||||
How to use .7z Decoder
|
||||
----------------------
|
||||
|
||||
.7z Decoder can be compiled in one of two modes:
|
||||
|
||||
1) Default mode. In that mode 7z Decoder will read full compressed
|
||||
block to RAM before decompressing.
|
||||
|
||||
2) Mode with defined _LZMA_IN_CB. In that mode 7z Decoder can read
|
||||
compressed block by parts. And you can specify desired buffer size.
|
||||
So memory requirements can be reduced. But decompressing speed will
|
||||
be 5-10% lower and code size is slightly larger.
|
||||
|
||||
|
||||
Memory allocation
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
7z Decoder uses two memory pools:
|
||||
1) Temporary pool
|
||||
2) Main pool
|
||||
Such scheme can allow you to avoid fragmentation of allocated blocks.
|
||||
|
||||
Steps for using 7z decoder
|
||||
--------------------------
|
||||
|
||||
Use code at 7zMain.c as example.
|
||||
|
||||
1) Declare variables:
|
||||
inStream /* implements ISzInStream interface */
|
||||
CArchiveDatabaseEx db; /* 7z archive database structure */
|
||||
ISzAlloc allocImp; /* memory functions for main pool */
|
||||
ISzAlloc allocTempImp; /* memory functions for temporary pool */
|
||||
|
||||
2) call InitCrcTable(); function to initialize CRC structures.
|
||||
|
||||
3) call SzArDbExInit(&db); function to initialize db structures.
|
||||
|
||||
4) call SzArchiveOpen(inStream, &db, &allocMain, &allocTemp) to open archive
|
||||
|
||||
This function opens archive "inStream" and reads headers to "db".
|
||||
All items in "db" will be allocated with "allocMain" functions.
|
||||
SzArchiveOpen function allocates and frees temporary structures by "allocTemp" functions.
|
||||
|
||||
5) List items or Extract items
|
||||
|
||||
Listing code:
|
||||
~~~~~~~~~~~~~
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < db.Database.NumFiles; i++)
|
||||
{
|
||||
CFileItem *f = db.Database.Files + i;
|
||||
printf("%10d %s\n", (int)f->Size, f->Name);
|
||||
}
|
||||
}
|
||||
|
||||
Extracting code:
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
SZ_RESULT SzExtract(
|
||||
ISzInStream *inStream,
|
||||
CArchiveDatabaseEx *db,
|
||||
UInt32 fileIndex, /* index of file */
|
||||
UInt32 *blockIndex, /* index of solid block */
|
||||
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
|
||||
size_t *outBufferSize, /* buffer size for output buffer */
|
||||
size_t *offset, /* offset of stream for required file in *outBuffer */
|
||||
size_t *outSizeProcessed, /* size of file in *outBuffer */
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp);
|
||||
|
||||
If you need to decompress more than one file, you can send these values from previous call:
|
||||
blockIndex,
|
||||
outBuffer,
|
||||
outBufferSize,
|
||||
You can consider "outBuffer" as cache of solid block. If your archive is solid,
|
||||
it will increase decompression speed.
|
||||
|
||||
After decompressing you must free "outBuffer":
|
||||
allocImp.Free(outBuffer);
|
||||
|
||||
6) call SzArDbExFree(&db, allocImp.Free) to free allocated items in "db".
|
||||
|
||||
|
||||
|
||||
|
||||
Memory requirements for .7z decoding
|
||||
------------------------------------
|
||||
|
||||
Memory usage for Archive opening:
|
||||
- Temporary pool:
|
||||
- Memory for compressed .7z headers (if _LZMA_IN_CB is not defined)
|
||||
- Memory for uncompressed .7z headers
|
||||
- some other temporary blocks
|
||||
- Main pool:
|
||||
- Memory for database:
|
||||
Estimated size of one file structures in solid archive:
|
||||
- Size (4 or 8 Bytes)
|
||||
- CRC32 (4 bytes)
|
||||
- LastWriteTime (8 bytes)
|
||||
- Some file information (4 bytes)
|
||||
- File Name (variable length) + pointer + allocation structures
|
||||
|
||||
Memory usage for archive Decompressing:
|
||||
- Temporary pool:
|
||||
- Memory for compressed solid block (if _LZMA_IN_CB is not defined)
|
||||
- Memory for LZMA decompressing structures
|
||||
- Main pool:
|
||||
- Memory for decompressed solid block
|
||||
- Memory for temprorary buffers, if BCJ2 fileter is used. Usually these
|
||||
temprorary buffers can be about 15% of solid block size.
|
||||
|
||||
|
||||
If _LZMA_IN_CB is defined, 7z Decoder will not allocate memory for
|
||||
compressed blocks. Instead of this, you must allocate buffer with desired
|
||||
size before calling 7z Decoder. Use 7zMain.c as example.
|
||||
|
||||
|
||||
|
||||
EXIT codes
|
||||
-----------
|
||||
|
||||
7z Decoder functions can return one of the following codes:
|
||||
|
||||
#define SZ_OK (0)
|
||||
#define SZE_DATA_ERROR (1)
|
||||
#define SZE_OUTOFMEMORY (2)
|
||||
#define SZE_CRC_ERROR (3)
|
||||
|
||||
#define SZE_NOTIMPL (4)
|
||||
#define SZE_FAIL (5)
|
||||
|
||||
#define SZE_ARCHIVE_ERROR (6)
|
||||
|
||||
|
||||
|
||||
LZMA Defines
|
||||
------------
|
||||
|
||||
_LZMA_IN_CB - Use special callback mode for input stream to reduce memory requirements
|
||||
|
||||
_SZ_FILE_SIZE_32 - define it if you need only support for files smaller than 4 GB
|
||||
_SZ_NO_INT_64 - define it if your compiler doesn't support long long int or __int64.
|
||||
|
||||
_LZMA_PROB32 - it can increase LZMA decompressing speed on some 32-bit CPUs.
|
||||
|
||||
_SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr.
|
||||
|
||||
|
||||
---
|
||||
|
||||
http://www.7-zip.org
|
||||
http://www.7-zip.org/support.html
|
|
@ -0,0 +1,32 @@
|
|||
/* 7zCrc.c */
|
||||
|
||||
#include "7zCrc.h"
|
||||
|
||||
#define kCrcPoly 0xEDB88320
|
||||
UInt32 g_CrcTable[256];
|
||||
|
||||
void MY_FAST_CALL CrcGenerateTable(void)
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
UInt32 r = i;
|
||||
int j;
|
||||
for (j = 0; j < 8; j++)
|
||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||
g_CrcTable[i] = r;
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
||||
{
|
||||
const Byte *p = (const Byte *)data;
|
||||
for (; size > 0 ; size--, p++)
|
||||
v = CRC_UPDATE_BYTE(v, *p);
|
||||
return v;
|
||||
}
|
||||
|
||||
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
|
||||
{
|
||||
return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/* 7zCrc.h */
|
||||
|
||||
#ifndef __7Z_CRC_H
|
||||
#define __7Z_CRC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
extern UInt32 g_CrcTable[];
|
||||
|
||||
void MY_FAST_CALL CrcGenerateTable(void);
|
||||
|
||||
#define CRC_INIT_VAL 0xFFFFFFFF
|
||||
#define CRC_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFF)
|
||||
#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||
|
||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
|
||||
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,119 @@
|
|||
/* Alloc.c */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Alloc.h"
|
||||
|
||||
/* #define _SZ_ALLOC_DEBUG */
|
||||
|
||||
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
#include <stdio.h>
|
||||
int g_allocCount = 0;
|
||||
int g_allocCountMid = 0;
|
||||
int g_allocCountBig = 0;
|
||||
#endif
|
||||
|
||||
void *MyAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount++);
|
||||
#endif
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void MyFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
fprintf(stderr, "\nFree; count = %10d", --g_allocCount);
|
||||
#endif
|
||||
free(address);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void *MidAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
|
||||
#endif
|
||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void MidFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
|
||||
#endif
|
||||
if (address == 0)
|
||||
return;
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
#ifndef MEM_LARGE_PAGES
|
||||
#undef _7ZIP_LARGE_PAGES
|
||||
#endif
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
SIZE_T g_LargePageSize = 0;
|
||||
typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
||||
#endif
|
||||
|
||||
void SetLargePageSize()
|
||||
{
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
SIZE_T size = 0;
|
||||
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
||||
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||
if (largePageMinimum == 0)
|
||||
return;
|
||||
size = largePageMinimum();
|
||||
if (size == 0 || (size & (size - 1)) != 0)
|
||||
return;
|
||||
g_LargePageSize = size;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void *BigAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
||||
#endif
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
|
||||
{
|
||||
void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
||||
MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||
if (res != 0)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void BigFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
|
||||
#endif
|
||||
|
||||
if (address == 0)
|
||||
return;
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,29 @@
|
|||
/* Alloc.h */
|
||||
|
||||
#ifndef __COMMON_ALLOC_H
|
||||
#define __COMMON_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *MyAlloc(size_t size);
|
||||
void MyFree(void *address);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void SetLargePageSize();
|
||||
|
||||
void *MidAlloc(size_t size);
|
||||
void MidFree(void *address);
|
||||
void *BigAlloc(size_t size);
|
||||
void BigFree(void *address);
|
||||
|
||||
#else
|
||||
|
||||
#define MidAlloc(size) MyAlloc(size)
|
||||
#define MidFree(address) MyFree(address)
|
||||
#define BigAlloc(size) MyAlloc(size)
|
||||
#define BigFree(address) MyFree(address)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,70 @@
|
|||
/* 7zAlloc.c */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "7zAlloc.h"
|
||||
|
||||
/* #define _SZ_ALLOC_DEBUG */
|
||||
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
||||
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
int g_allocCount = 0;
|
||||
int g_allocCountTemp = 0;
|
||||
#endif
|
||||
|
||||
void *SzAlloc(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount);
|
||||
g_allocCount++;
|
||||
#endif
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void SzFree(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
{
|
||||
g_allocCount--;
|
||||
fprintf(stderr, "\nFree; count = %10d", g_allocCount);
|
||||
}
|
||||
#endif
|
||||
free(address);
|
||||
}
|
||||
|
||||
void *SzAllocTemp(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp);
|
||||
g_allocCountTemp++;
|
||||
#ifdef _WIN32
|
||||
return HeapAlloc(GetProcessHeap(), 0, size);
|
||||
#endif
|
||||
#endif
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void SzFreeTemp(void *address)
|
||||
{
|
||||
#ifdef _SZ_ALLOC_DEBUG
|
||||
if (address != 0)
|
||||
{
|
||||
g_allocCountTemp--;
|
||||
fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
HeapFree(GetProcessHeap(), 0, address);
|
||||
return;
|
||||
#endif
|
||||
#endif
|
||||
free(address);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/* 7zAlloc.h */
|
||||
|
||||
#ifndef __7Z_ALLOC_H
|
||||
#define __7Z_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct _ISzAlloc
|
||||
{
|
||||
void *(*Alloc)(size_t size);
|
||||
void (*Free)(void *address); /* address can be 0 */
|
||||
} ISzAlloc;
|
||||
|
||||
void *SzAlloc(size_t size);
|
||||
void SzFree(void *address);
|
||||
|
||||
void *SzAllocTemp(size_t size);
|
||||
void SzFreeTemp(void *address);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,29 @@
|
|||
/* 7zBuffer.c */
|
||||
|
||||
#include "7zBuffer.h"
|
||||
#include "7zAlloc.h"
|
||||
|
||||
void SzByteBufferInit(CSzByteBuffer *buffer)
|
||||
{
|
||||
buffer->Capacity = 0;
|
||||
buffer->Items = 0;
|
||||
}
|
||||
|
||||
int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size))
|
||||
{
|
||||
buffer->Capacity = newCapacity;
|
||||
if (newCapacity == 0)
|
||||
{
|
||||
buffer->Items = 0;
|
||||
return 1;
|
||||
}
|
||||
buffer->Items = (Byte *)allocFunc(newCapacity);
|
||||
return (buffer->Items != 0);
|
||||
}
|
||||
|
||||
void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *))
|
||||
{
|
||||
freeFunc(buffer->Items);
|
||||
buffer->Items = 0;
|
||||
buffer->Capacity = 0;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/* 7zBuffer.h */
|
||||
|
||||
#ifndef __7Z_BUFFER_H
|
||||
#define __7Z_BUFFER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "../../Types.h"
|
||||
|
||||
typedef struct _CSzByteBuffer
|
||||
{
|
||||
size_t Capacity;
|
||||
Byte *Items;
|
||||
}CSzByteBuffer;
|
||||
|
||||
void SzByteBufferInit(CSzByteBuffer *buffer);
|
||||
int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size));
|
||||
void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *));
|
||||
|
||||
#endif
|
|
@ -0,0 +1,347 @@
|
|||
/* 7zDecode.c */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "7zDecode.h"
|
||||
#ifdef _SZ_ONE_DIRECTORY
|
||||
#include "LzmaDecode.h"
|
||||
#else
|
||||
#include "../../Compress/Lzma/LzmaDecode.h"
|
||||
#include "../../Compress/Branch/BranchX86.h"
|
||||
#include "../../Compress/Branch/BranchX86_2.h"
|
||||
#endif
|
||||
|
||||
#define k_Copy 0
|
||||
#define k_LZMA 0x30101
|
||||
#define k_BCJ 0x03030103
|
||||
#define k_BCJ2 0x0303011B
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
|
||||
typedef struct _CLzmaInCallbackImp
|
||||
{
|
||||
ILzmaInCallback InCallback;
|
||||
ISzInStream *InStream;
|
||||
CFileSize Size;
|
||||
} CLzmaInCallbackImp;
|
||||
|
||||
static
|
||||
int LzmaReadImp(void *object, const unsigned char **buffer, SizeT *size)
|
||||
{
|
||||
CLzmaInCallbackImp *cb = (CLzmaInCallbackImp *)object;
|
||||
size_t processedSize;
|
||||
SZ_RESULT res;
|
||||
size_t curSize = (1 << 20);
|
||||
if (curSize > cb->Size)
|
||||
curSize = (size_t)cb->Size;
|
||||
*size = 0;
|
||||
res = cb->InStream->Read((void *)cb->InStream, (void **)buffer, curSize, &processedSize);
|
||||
*size = (SizeT)processedSize;
|
||||
if (processedSize > curSize)
|
||||
return (int)SZE_FAIL;
|
||||
cb->Size -= processedSize;
|
||||
if (res == SZ_OK)
|
||||
return 0;
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static
|
||||
SZ_RESULT SzDecodeLzma(CCoderInfo *coder, CFileSize inSize,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ISzInStream *inStream,
|
||||
#else
|
||||
const Byte *inBuffer,
|
||||
#endif
|
||||
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain)
|
||||
{
|
||||
#ifdef _LZMA_IN_CB
|
||||
CLzmaInCallbackImp lzmaCallback;
|
||||
#else
|
||||
SizeT inProcessed;
|
||||
#endif
|
||||
|
||||
CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
|
||||
int result;
|
||||
SizeT outSizeProcessedLoc;
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
lzmaCallback.Size = inSize;
|
||||
lzmaCallback.InStream = inStream;
|
||||
lzmaCallback.InCallback.Read = LzmaReadImp;
|
||||
#endif
|
||||
|
||||
if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items,
|
||||
(unsigned)coder->Properties.Capacity) != LZMA_RESULT_OK)
|
||||
return SZE_FAIL;
|
||||
|
||||
state.Probs = (CProb *)allocMain->Alloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
|
||||
if (state.Probs == 0)
|
||||
return SZE_OUTOFMEMORY;
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
if (state.Properties.DictionarySize == 0)
|
||||
state.Dictionary = 0;
|
||||
else
|
||||
{
|
||||
state.Dictionary = (unsigned char *)allocMain->Alloc(state.Properties.DictionarySize);
|
||||
if (state.Dictionary == 0)
|
||||
{
|
||||
allocMain->Free(state.Probs);
|
||||
return SZE_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
LzmaDecoderInit(&state);
|
||||
#endif
|
||||
|
||||
result = LzmaDecode(&state,
|
||||
#ifdef _LZMA_IN_CB
|
||||
&lzmaCallback.InCallback,
|
||||
#else
|
||||
inBuffer, (SizeT)inSize, &inProcessed,
|
||||
#endif
|
||||
outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
|
||||
allocMain->Free(state.Probs);
|
||||
#ifdef _LZMA_OUT_READ
|
||||
allocMain->Free(state.Dictionary);
|
||||
#endif
|
||||
if (result == LZMA_RESULT_DATA_ERROR)
|
||||
return SZE_DATA_ERROR;
|
||||
if (result != LZMA_RESULT_OK)
|
||||
return SZE_FAIL;
|
||||
return (outSizeProcessedLoc == outSize) ? SZ_OK : SZE_DATA_ERROR;
|
||||
}
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
static
|
||||
SZ_RESULT SzDecodeCopy(CFileSize inSize, ISzInStream *inStream, Byte *outBuffer)
|
||||
{
|
||||
while (inSize > 0)
|
||||
{
|
||||
void *inBuffer;
|
||||
size_t processedSize, curSize = (1 << 18);
|
||||
if (curSize > inSize)
|
||||
curSize = (size_t)(inSize);
|
||||
RINOK(inStream->Read((void *)inStream, (void **)&inBuffer, curSize, &processedSize));
|
||||
if (processedSize == 0)
|
||||
return SZE_DATA_ERROR;
|
||||
if (processedSize > curSize)
|
||||
return SZE_FAIL;
|
||||
memcpy(outBuffer, inBuffer, processedSize);
|
||||
outBuffer += processedSize;
|
||||
inSize -= processedSize;
|
||||
}
|
||||
return SZ_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define IS_UNSUPPORTED_METHOD(m) ((m) != k_Copy && (m) != k_LZMA)
|
||||
#define IS_UNSUPPORTED_CODER(c) (IS_UNSUPPORTED_METHOD(c.MethodID) || c.NumInStreams != 1 || c.NumOutStreams != 1)
|
||||
#define IS_NO_BCJ(c) (c.MethodID != k_BCJ || c.NumInStreams != 1 || c.NumOutStreams != 1)
|
||||
#define IS_NO_BCJ2(c) (c.MethodID != k_BCJ2 || c.NumInStreams != 4 || c.NumOutStreams != 1)
|
||||
|
||||
static
|
||||
SZ_RESULT CheckSupportedFolder(const CFolder *f)
|
||||
{
|
||||
if (f->NumCoders < 1 || f->NumCoders > 4)
|
||||
return SZE_NOTIMPL;
|
||||
if (IS_UNSUPPORTED_CODER(f->Coders[0]))
|
||||
return SZE_NOTIMPL;
|
||||
if (f->NumCoders == 1)
|
||||
{
|
||||
if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0)
|
||||
return SZE_NOTIMPL;
|
||||
return SZ_OK;
|
||||
}
|
||||
if (f->NumCoders == 2)
|
||||
{
|
||||
if (IS_NO_BCJ(f->Coders[1]) ||
|
||||
f->NumPackStreams != 1 || f->PackStreams[0] != 0 ||
|
||||
f->NumBindPairs != 1 ||
|
||||
f->BindPairs[0].InIndex != 1 || f->BindPairs[0].OutIndex != 0)
|
||||
return SZE_NOTIMPL;
|
||||
return SZ_OK;
|
||||
}
|
||||
if (f->NumCoders == 4)
|
||||
{
|
||||
if (IS_UNSUPPORTED_CODER(f->Coders[1]) ||
|
||||
IS_UNSUPPORTED_CODER(f->Coders[2]) ||
|
||||
IS_NO_BCJ2(f->Coders[3]))
|
||||
return SZE_NOTIMPL;
|
||||
if (f->NumPackStreams != 4 ||
|
||||
f->PackStreams[0] != 2 ||
|
||||
f->PackStreams[1] != 6 ||
|
||||
f->PackStreams[2] != 1 ||
|
||||
f->PackStreams[3] != 0 ||
|
||||
f->NumBindPairs != 3 ||
|
||||
f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 ||
|
||||
f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 ||
|
||||
f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2)
|
||||
return SZE_NOTIMPL;
|
||||
return SZ_OK;
|
||||
}
|
||||
return SZE_NOTIMPL;
|
||||
}
|
||||
|
||||
static
|
||||
CFileSize GetSum(const CFileSize *values, UInt32 index)
|
||||
{
|
||||
CFileSize sum = 0;
|
||||
UInt32 i;
|
||||
for (i = 0; i < index; i++)
|
||||
sum += values[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
static
|
||||
SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ISzInStream *inStream, CFileSize startPos,
|
||||
#else
|
||||
const Byte *inBuffer,
|
||||
#endif
|
||||
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain,
|
||||
Byte *tempBuf[])
|
||||
{
|
||||
UInt32 ci;
|
||||
size_t tempSizes[3] = { 0, 0, 0};
|
||||
size_t tempSize3 = 0;
|
||||
Byte *tempBuf3 = 0;
|
||||
|
||||
RINOK(CheckSupportedFolder(folder));
|
||||
|
||||
for (ci = 0; ci < folder->NumCoders; ci++)
|
||||
{
|
||||
CCoderInfo *coder = &folder->Coders[ci];
|
||||
|
||||
if (coder->MethodID == k_Copy || coder->MethodID == k_LZMA)
|
||||
{
|
||||
UInt32 si = 0;
|
||||
CFileSize offset;
|
||||
CFileSize inSize;
|
||||
Byte *outBufCur = outBuffer;
|
||||
size_t outSizeCur = outSize;
|
||||
if (folder->NumCoders == 4)
|
||||
{
|
||||
UInt32 indices[] = { 3, 2, 0 };
|
||||
CFileSize unpackSize = folder->UnPackSizes[ci];
|
||||
si = indices[ci];
|
||||
if (ci < 2)
|
||||
{
|
||||
Byte *temp;
|
||||
outSizeCur = (size_t)unpackSize;
|
||||
if (outSizeCur != unpackSize)
|
||||
return SZE_OUTOFMEMORY;
|
||||
temp = (Byte *)allocMain->Alloc(outSizeCur);
|
||||
if (temp == 0 && outSizeCur != 0)
|
||||
return SZE_OUTOFMEMORY;
|
||||
outBufCur = tempBuf[1 - ci] = temp;
|
||||
tempSizes[1 - ci] = outSizeCur;
|
||||
}
|
||||
else if (ci == 2)
|
||||
{
|
||||
if (unpackSize > outSize)
|
||||
return SZE_OUTOFMEMORY;
|
||||
tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize);
|
||||
tempSize3 = outSizeCur = (size_t)unpackSize;
|
||||
}
|
||||
else
|
||||
return SZE_NOTIMPL;
|
||||
}
|
||||
offset = GetSum(packSizes, si);
|
||||
inSize = packSizes[si];
|
||||
#ifdef _LZMA_IN_CB
|
||||
RINOK(inStream->Seek(inStream, startPos + offset));
|
||||
#endif
|
||||
|
||||
if (coder->MethodID == k_Copy)
|
||||
{
|
||||
if (inSize != outSizeCur)
|
||||
return SZE_DATA_ERROR;
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
RINOK(SzDecodeCopy(inSize, inStream, outBufCur));
|
||||
#else
|
||||
memcpy(outBufCur, inBuffer + (size_t)offset, (size_t)inSize);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
SZ_RESULT res = SzDecodeLzma(coder, inSize,
|
||||
#ifdef _LZMA_IN_CB
|
||||
inStream,
|
||||
#else
|
||||
inBuffer + (size_t)offset,
|
||||
#endif
|
||||
outBufCur, outSizeCur, allocMain);
|
||||
RINOK(res)
|
||||
}
|
||||
}
|
||||
else if (coder->MethodID == k_BCJ)
|
||||
{
|
||||
UInt32 state;
|
||||
if (ci != 1)
|
||||
return SZE_NOTIMPL;
|
||||
x86_Convert_Init(state);
|
||||
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
||||
}
|
||||
else if (coder->MethodID == k_BCJ2)
|
||||
{
|
||||
CFileSize offset = GetSum(packSizes, 1);
|
||||
CFileSize s3Size = packSizes[1];
|
||||
SZ_RESULT res;
|
||||
if (ci != 3)
|
||||
return SZE_NOTIMPL;
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
RINOK(inStream->Seek(inStream, startPos + offset));
|
||||
tempSizes[2] = (size_t)s3Size;
|
||||
if (tempSizes[2] != s3Size)
|
||||
return SZE_OUTOFMEMORY;
|
||||
tempBuf[2] = (Byte *)allocMain->Alloc(tempSizes[2]);
|
||||
if (tempBuf[2] == 0 && tempSizes[2] != 0)
|
||||
return SZE_OUTOFMEMORY;
|
||||
res = SzDecodeCopy(s3Size, inStream, tempBuf[2]);
|
||||
RINOK(res)
|
||||
#endif
|
||||
|
||||
res = x86_2_Decode(
|
||||
tempBuf3, tempSize3,
|
||||
tempBuf[0], tempSizes[0],
|
||||
tempBuf[1], tempSizes[1],
|
||||
#ifdef _LZMA_IN_CB
|
||||
tempBuf[2], tempSizes[2],
|
||||
#else
|
||||
inBuffer + (size_t)offset, (size_t)s3Size,
|
||||
#endif
|
||||
outBuffer, outSize);
|
||||
RINOK(res)
|
||||
}
|
||||
else
|
||||
return SZE_NOTIMPL;
|
||||
}
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ISzInStream *inStream, CFileSize startPos,
|
||||
#else
|
||||
const Byte *inBuffer,
|
||||
#endif
|
||||
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain)
|
||||
{
|
||||
Byte *tempBuf[3] = { 0, 0, 0};
|
||||
int i;
|
||||
SZ_RESULT res = SzDecode2(packSizes, folder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
inStream, startPos,
|
||||
#else
|
||||
inBuffer,
|
||||
#endif
|
||||
outBuffer, outSize, allocMain, tempBuf);
|
||||
for (i = 0; i < 3; i++)
|
||||
allocMain->Free(tempBuf[i]);
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/* 7zDecode.h */
|
||||
|
||||
#ifndef __7Z_DECODE_H
|
||||
#define __7Z_DECODE_H
|
||||
|
||||
#include "7zItem.h"
|
||||
#include "7zAlloc.h"
|
||||
#include "7zIn.h"
|
||||
|
||||
SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ISzInStream *stream, CFileSize startPos,
|
||||
#else
|
||||
const Byte *inBuffer,
|
||||
#endif
|
||||
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,119 @@
|
|||
/* 7zExtract.c */
|
||||
|
||||
#include "7zExtract.h"
|
||||
#include "7zDecode.h"
|
||||
#include "../../7zCrc.h"
|
||||
|
||||
SZ_RESULT SzExtract(
|
||||
ISzInStream *inStream,
|
||||
CArchiveDatabaseEx *db,
|
||||
UInt32 fileIndex,
|
||||
UInt32 *blockIndex,
|
||||
Byte **outBuffer,
|
||||
size_t *outBufferSize,
|
||||
size_t *offset,
|
||||
size_t *outSizeProcessed,
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp)
|
||||
{
|
||||
UInt32 folderIndex = db->FileIndexToFolderIndexMap[fileIndex];
|
||||
SZ_RESULT res = SZ_OK;
|
||||
*offset = 0;
|
||||
*outSizeProcessed = 0;
|
||||
if (folderIndex == (UInt32)-1)
|
||||
{
|
||||
allocMain->Free(*outBuffer);
|
||||
*blockIndex = folderIndex;
|
||||
*outBuffer = 0;
|
||||
*outBufferSize = 0;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
if (*outBuffer == 0 || *blockIndex != folderIndex)
|
||||
{
|
||||
CFolder *folder = db->Database.Folders + folderIndex;
|
||||
CFileSize unPackSizeSpec = SzFolderGetUnPackSize(folder);
|
||||
size_t unPackSize = (size_t)unPackSizeSpec;
|
||||
CFileSize startOffset = SzArDbGetFolderStreamPos(db, folderIndex, 0);
|
||||
#ifndef _LZMA_IN_CB
|
||||
Byte *inBuffer = 0;
|
||||
size_t processedSize;
|
||||
CFileSize packSizeSpec;
|
||||
size_t packSize;
|
||||
RINOK(SzArDbGetFolderFullPackSize(db, folderIndex, &packSizeSpec));
|
||||
packSize = (size_t)packSizeSpec;
|
||||
if (packSize != packSizeSpec)
|
||||
return SZE_OUTOFMEMORY;
|
||||
#endif
|
||||
if (unPackSize != unPackSizeSpec)
|
||||
return SZE_OUTOFMEMORY;
|
||||
*blockIndex = folderIndex;
|
||||
allocMain->Free(*outBuffer);
|
||||
*outBuffer = 0;
|
||||
|
||||
RINOK(inStream->Seek(inStream, startOffset));
|
||||
|
||||
#ifndef _LZMA_IN_CB
|
||||
if (packSize != 0)
|
||||
{
|
||||
inBuffer = (Byte *)allocTemp->Alloc(packSize);
|
||||
if (inBuffer == 0)
|
||||
return SZE_OUTOFMEMORY;
|
||||
}
|
||||
res = inStream->Read(inStream, inBuffer, packSize, &processedSize);
|
||||
if (res == SZ_OK && processedSize != packSize)
|
||||
res = SZE_FAIL;
|
||||
#endif
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
*outBufferSize = unPackSize;
|
||||
if (unPackSize != 0)
|
||||
{
|
||||
*outBuffer = (Byte *)allocMain->Alloc(unPackSize);
|
||||
if (*outBuffer == 0)
|
||||
res = SZE_OUTOFMEMORY;
|
||||
}
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
res = SzDecode(db->Database.PackSizes +
|
||||
db->FolderStartPackStreamIndex[folderIndex], folder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
inStream, startOffset,
|
||||
#else
|
||||
inBuffer,
|
||||
#endif
|
||||
*outBuffer, unPackSize, allocTemp);
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
if (folder->UnPackCRCDefined)
|
||||
{
|
||||
if (CrcCalc(*outBuffer, unPackSize) != folder->UnPackCRC)
|
||||
res = SZE_CRC_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef _LZMA_IN_CB
|
||||
allocTemp->Free(inBuffer);
|
||||
#endif
|
||||
}
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
UInt32 i;
|
||||
CFileItem *fileItem = db->Database.Files + fileIndex;
|
||||
*offset = 0;
|
||||
for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
|
||||
*offset += (UInt32)db->Database.Files[i].Size;
|
||||
*outSizeProcessed = (size_t)fileItem->Size;
|
||||
if (*offset + *outSizeProcessed > *outBufferSize)
|
||||
return SZE_FAIL;
|
||||
{
|
||||
if (fileItem->IsFileCRCDefined)
|
||||
{
|
||||
if (CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->FileCRC)
|
||||
res = SZE_CRC_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/* 7zExtract.h */
|
||||
|
||||
#ifndef __7Z_EXTRACT_H
|
||||
#define __7Z_EXTRACT_H
|
||||
|
||||
#include "7zIn.h"
|
||||
|
||||
/*
|
||||
SzExtract extracts file from archive
|
||||
|
||||
*outBuffer must be 0 before first call for each new archive.
|
||||
|
||||
Extracting cache:
|
||||
If you need to decompress more than one file, you can send
|
||||
these values from previous call:
|
||||
*blockIndex,
|
||||
*outBuffer,
|
||||
*outBufferSize
|
||||
You can consider "*outBuffer" as cache of solid block. If your archive is solid,
|
||||
it will increase decompression speed.
|
||||
|
||||
If you use external function, you can declare these 3 cache variables
|
||||
(blockIndex, outBuffer, outBufferSize) as static in that external function.
|
||||
|
||||
Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
|
||||
*/
|
||||
|
||||
SZ_RESULT SzExtract(
|
||||
ISzInStream *inStream,
|
||||
CArchiveDatabaseEx *db,
|
||||
UInt32 fileIndex, /* index of file */
|
||||
UInt32 *blockIndex, /* index of solid block */
|
||||
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
|
||||
size_t *outBufferSize, /* buffer size for output buffer */
|
||||
size_t *offset, /* offset of stream for required file in *outBuffer */
|
||||
size_t *outSizeProcessed, /* size of file in *outBuffer */
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
/* 7zHeader.c */
|
||||
|
||||
#include "7zHeader.h"
|
||||
|
||||
Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
|
@ -0,0 +1,55 @@
|
|||
/* 7zHeader.h */
|
||||
|
||||
#ifndef __7Z_HEADER_H
|
||||
#define __7Z_HEADER_H
|
||||
|
||||
#include "../../Types.h"
|
||||
|
||||
#define k7zSignatureSize 6
|
||||
extern Byte k7zSignature[k7zSignatureSize];
|
||||
|
||||
#define k7zMajorVersion 0
|
||||
|
||||
#define k7zStartHeaderSize 0x20
|
||||
|
||||
enum EIdEnum
|
||||
{
|
||||
k7zIdEnd,
|
||||
|
||||
k7zIdHeader,
|
||||
|
||||
k7zIdArchiveProperties,
|
||||
|
||||
k7zIdAdditionalStreamsInfo,
|
||||
k7zIdMainStreamsInfo,
|
||||
k7zIdFilesInfo,
|
||||
|
||||
k7zIdPackInfo,
|
||||
k7zIdUnPackInfo,
|
||||
k7zIdSubStreamsInfo,
|
||||
|
||||
k7zIdSize,
|
||||
k7zIdCRC,
|
||||
|
||||
k7zIdFolder,
|
||||
|
||||
k7zIdCodersUnPackSize,
|
||||
k7zIdNumUnPackStream,
|
||||
|
||||
k7zIdEmptyStream,
|
||||
k7zIdEmptyFile,
|
||||
k7zIdAnti,
|
||||
|
||||
k7zIdName,
|
||||
k7zIdCreationTime,
|
||||
k7zIdLastAccessTime,
|
||||
k7zIdLastWriteTime,
|
||||
k7zIdWinAttributes,
|
||||
k7zIdComment,
|
||||
|
||||
k7zIdEncodedHeader,
|
||||
|
||||
k7zIdStartPos
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
|||
/* 7zIn.h */
|
||||
|
||||
#ifndef __7Z_IN_H
|
||||
#define __7Z_IN_H
|
||||
|
||||
#include "7zHeader.h"
|
||||
#include "7zItem.h"
|
||||
#include "7zAlloc.h"
|
||||
#include "../../Compress/Lzma/LzmaDecode.h"
|
||||
|
||||
typedef struct _CInArchiveInfo
|
||||
{
|
||||
CFileSize StartPositionAfterHeader;
|
||||
CFileSize DataStartPosition;
|
||||
}CInArchiveInfo;
|
||||
|
||||
typedef struct _CArchiveDatabaseEx
|
||||
{
|
||||
CArchiveDatabase Database;
|
||||
CInArchiveInfo ArchiveInfo;
|
||||
UInt32 *FolderStartPackStreamIndex;
|
||||
CFileSize *PackStreamStartPositions;
|
||||
UInt32 *FolderStartFileIndex;
|
||||
UInt32 *FileIndexToFolderIndexMap;
|
||||
}CArchiveDatabaseEx;
|
||||
|
||||
void SzArDbExInit(CArchiveDatabaseEx *db);
|
||||
void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *));
|
||||
CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder);
|
||||
int SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex, CFileSize *resSize);
|
||||
|
||||
typedef struct _ISzInStream
|
||||
{
|
||||
#ifdef _LZMA_IN_CB
|
||||
SZ_RESULT (*Read)(
|
||||
void *object, /* pointer to ISzInStream itself */
|
||||
void **buffer, /* out: pointer to buffer with data */
|
||||
size_t maxRequiredSize, /* max required size to read */
|
||||
size_t *processedSize); /* real processed size.
|
||||
processedSize can be less than maxRequiredSize.
|
||||
If processedSize == 0, then there are no more
|
||||
bytes in stream. */
|
||||
#else
|
||||
SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize);
|
||||
#endif
|
||||
SZ_RESULT (*Seek)(void *object, CFileSize pos);
|
||||
} ISzInStream;
|
||||
|
||||
|
||||
int SzArchiveOpen(
|
||||
ISzInStream *inStream,
|
||||
CArchiveDatabaseEx *db,
|
||||
ISzAlloc *allocMain,
|
||||
ISzAlloc *allocTemp);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,140 @@
|
|||
/* 7zItem.c */
|
||||
|
||||
#include "7zItem.h"
|
||||
#include "7zAlloc.h"
|
||||
|
||||
void SzCoderInfoInit(CCoderInfo *coder)
|
||||
{
|
||||
SzByteBufferInit(&coder->Properties);
|
||||
}
|
||||
|
||||
void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p))
|
||||
{
|
||||
SzByteBufferFree(&coder->Properties, freeFunc);
|
||||
SzCoderInfoInit(coder);
|
||||
}
|
||||
|
||||
void SzFolderInit(CFolder *folder)
|
||||
{
|
||||
folder->NumCoders = 0;
|
||||
folder->Coders = 0;
|
||||
folder->NumBindPairs = 0;
|
||||
folder->BindPairs = 0;
|
||||
folder->NumPackStreams = 0;
|
||||
folder->PackStreams = 0;
|
||||
folder->UnPackSizes = 0;
|
||||
folder->UnPackCRCDefined = 0;
|
||||
folder->UnPackCRC = 0;
|
||||
folder->NumUnPackStreams = 0;
|
||||
}
|
||||
|
||||
static
|
||||
void SzFolderFree(CFolder *folder, void (*freeFunc)(void *p))
|
||||
{
|
||||
UInt32 i;
|
||||
if (folder->Coders)
|
||||
for (i = 0; i < folder->NumCoders; i++)
|
||||
SzCoderInfoFree(&folder->Coders[i], freeFunc);
|
||||
freeFunc(folder->Coders);
|
||||
freeFunc(folder->BindPairs);
|
||||
freeFunc(folder->PackStreams);
|
||||
freeFunc(folder->UnPackSizes);
|
||||
SzFolderInit(folder);
|
||||
}
|
||||
|
||||
UInt32 SzFolderGetNumOutStreams(CFolder *folder)
|
||||
{
|
||||
UInt32 result = 0;
|
||||
UInt32 i;
|
||||
for (i = 0; i < folder->NumCoders; i++)
|
||||
result += folder->Coders[i].NumOutStreams;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex)
|
||||
{
|
||||
UInt32 i;
|
||||
for(i = 0; i < folder->NumBindPairs; i++)
|
||||
if (folder->BindPairs[i].InIndex == inStreamIndex)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int SzFolderFindBindPairForOutStream(CFolder *folder, UInt32 outStreamIndex)
|
||||
{
|
||||
UInt32 i;
|
||||
for(i = 0; i < folder->NumBindPairs; i++)
|
||||
if (folder->BindPairs[i].OutIndex == outStreamIndex)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
CFileSize SzFolderGetUnPackSize(CFolder *folder)
|
||||
{
|
||||
int i = (int)SzFolderGetNumOutStreams(folder);
|
||||
if (i == 0)
|
||||
return 0;
|
||||
for (i--; i >= 0; i--)
|
||||
if (SzFolderFindBindPairForOutStream(folder, i) < 0)
|
||||
return folder->UnPackSizes[i];
|
||||
/* throw 1; */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int FindPackStreamArrayIndex(int inStreamIndex) const
|
||||
{
|
||||
for(int i = 0; i < PackStreams.Size(); i++)
|
||||
if (PackStreams[i] == inStreamIndex)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
void SzFileInit(CFileItem *fileItem)
|
||||
{
|
||||
fileItem->IsFileCRCDefined = 0;
|
||||
fileItem->HasStream = 1;
|
||||
fileItem->IsDirectory = 0;
|
||||
fileItem->IsAnti = 0;
|
||||
fileItem->IsLastWriteTimeDefined = 0;
|
||||
fileItem->Name = 0;
|
||||
}
|
||||
|
||||
static
|
||||
void SzFileFree(CFileItem *fileItem, void (*freeFunc)(void *p))
|
||||
{
|
||||
freeFunc(fileItem->Name);
|
||||
SzFileInit(fileItem);
|
||||
}
|
||||
|
||||
void SzArchiveDatabaseInit(CArchiveDatabase *db)
|
||||
{
|
||||
db->NumPackStreams = 0;
|
||||
db->PackSizes = 0;
|
||||
db->PackCRCsDefined = 0;
|
||||
db->PackCRCs = 0;
|
||||
db->NumFolders = 0;
|
||||
db->Folders = 0;
|
||||
db->NumFiles = 0;
|
||||
db->Files = 0;
|
||||
}
|
||||
|
||||
void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *))
|
||||
{
|
||||
UInt32 i;
|
||||
if (db->Folders)
|
||||
for (i = 0; i < db->NumFolders; i++)
|
||||
SzFolderFree(&db->Folders[i], freeFunc);
|
||||
if (db->Files)
|
||||
for (i = 0; i < db->NumFiles; i++)
|
||||
SzFileFree(&db->Files[i], freeFunc);
|
||||
freeFunc(db->PackSizes);
|
||||
freeFunc(db->PackCRCsDefined);
|
||||
freeFunc(db->PackCRCs);
|
||||
freeFunc(db->Folders);
|
||||
freeFunc(db->Files);
|
||||
SzArchiveDatabaseInit(db);
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/* 7zItem.h */
|
||||
|
||||
#ifndef __7Z_ITEM_H
|
||||
#define __7Z_ITEM_H
|
||||
|
||||
#include "7zMethodID.h"
|
||||
#include "7zHeader.h"
|
||||
#include "7zBuffer.h"
|
||||
|
||||
typedef struct _CCoderInfo
|
||||
{
|
||||
UInt32 NumInStreams;
|
||||
UInt32 NumOutStreams;
|
||||
CMethodID MethodID;
|
||||
CSzByteBuffer Properties;
|
||||
}CCoderInfo;
|
||||
|
||||
void SzCoderInfoInit(CCoderInfo *coder);
|
||||
void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p));
|
||||
|
||||
typedef struct _CBindPair
|
||||
{
|
||||
UInt32 InIndex;
|
||||
UInt32 OutIndex;
|
||||
}CBindPair;
|
||||
|
||||
typedef struct _CFolder
|
||||
{
|
||||
UInt32 NumCoders;
|
||||
CCoderInfo *Coders;
|
||||
UInt32 NumBindPairs;
|
||||
CBindPair *BindPairs;
|
||||
UInt32 NumPackStreams;
|
||||
UInt32 *PackStreams;
|
||||
CFileSize *UnPackSizes;
|
||||
int UnPackCRCDefined;
|
||||
UInt32 UnPackCRC;
|
||||
|
||||
UInt32 NumUnPackStreams;
|
||||
}CFolder;
|
||||
|
||||
void SzFolderInit(CFolder *folder);
|
||||
CFileSize SzFolderGetUnPackSize(CFolder *folder);
|
||||
int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex);
|
||||
UInt32 SzFolderGetNumOutStreams(CFolder *folder);
|
||||
/*CFileSize SzFolderGetUnPackSize(CFolder *folder);*/
|
||||
|
||||
typedef struct _CArchiveFileTime
|
||||
{
|
||||
UInt32 Low;
|
||||
UInt32 High;
|
||||
} CArchiveFileTime;
|
||||
|
||||
typedef struct _CFileItem
|
||||
{
|
||||
CArchiveFileTime LastWriteTime;
|
||||
/*
|
||||
CFileSize StartPos;
|
||||
UInt32 Attributes;
|
||||
*/
|
||||
CFileSize Size;
|
||||
UInt32 FileCRC;
|
||||
char *Name;
|
||||
|
||||
Byte IsFileCRCDefined;
|
||||
Byte HasStream;
|
||||
Byte IsDirectory;
|
||||
Byte IsAnti;
|
||||
Byte IsLastWriteTimeDefined;
|
||||
/*
|
||||
int AreAttributesDefined;
|
||||
int IsLastWriteTimeDefined;
|
||||
int IsStartPosDefined;
|
||||
*/
|
||||
}CFileItem;
|
||||
|
||||
void SzFileInit(CFileItem *fileItem);
|
||||
|
||||
typedef struct _CArchiveDatabase
|
||||
{
|
||||
UInt32 NumPackStreams;
|
||||
CFileSize *PackSizes;
|
||||
Byte *PackCRCsDefined;
|
||||
UInt32 *PackCRCs;
|
||||
UInt32 NumFolders;
|
||||
CFolder *Folders;
|
||||
UInt32 NumFiles;
|
||||
CFileItem *Files;
|
||||
}CArchiveDatabase;
|
||||
|
||||
void SzArchiveDatabaseInit(CArchiveDatabase *db);
|
||||
void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *));
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,10 @@
|
|||
/* 7zMethodID.c */
|
||||
|
||||
#include "7zMethodID.h"
|
||||
|
||||
/*
|
||||
int AreMethodsEqual(CMethodID *a1, CMethodID *a2)
|
||||
{
|
||||
return (*a1 == *a2) ? 1 : 0;
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,10 @@
|
|||
/* 7zMethodID.h */
|
||||
|
||||
#ifndef __7Z_METHOD_ID_H
|
||||
#define __7Z_METHOD_ID_H
|
||||
|
||||
#include "../../Types.h"
|
||||
|
||||
typedef UInt64 CMethodID;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,51 @@
|
|||
/* BranchTypes.h */
|
||||
|
||||
#ifndef __BRANCHTYPES_H
|
||||
#define __BRANCHTYPES_H
|
||||
|
||||
#ifndef _7ZIP_BYTE_DEFINED
|
||||
#define _7ZIP_BYTE_DEFINED
|
||||
typedef unsigned char Byte;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT16_DEFINED
|
||||
#define _7ZIP_UINT16_DEFINED
|
||||
typedef unsigned short UInt16;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT32_DEFINED
|
||||
#define _7ZIP_UINT32_DEFINED
|
||||
#ifdef _LZMA_UINT32_IS_ULONG
|
||||
typedef unsigned long UInt32;
|
||||
#else
|
||||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT64_DEFINED
|
||||
#define _7ZIP_UINT64_DEFINED
|
||||
#ifdef _SZ_NO_INT_64
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else
|
||||
typedef unsigned long long int UInt64;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* #define _LZMA_NO_SYSTEM_SIZE_T */
|
||||
/* You can use it, if you don't want <stddef.h> */
|
||||
|
||||
#ifndef _7ZIP_SIZET_DEFINED
|
||||
#define _7ZIP_SIZET_DEFINED
|
||||
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
||||
typedef UInt32 SizeT;
|
||||
#else
|
||||
#include <stddef.h>
|
||||
typedef size_t SizeT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,84 @@
|
|||
/* BranchX86.c */
|
||||
|
||||
#include "BranchX86.h"
|
||||
|
||||
#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
|
||||
|
||||
const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
|
||||
const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
|
||||
|
||||
SizeT x86_Convert(Byte *buffer, SizeT endPos, UInt32 nowPos, UInt32 *prevMaskMix, int encoding)
|
||||
{
|
||||
SizeT bufferPos = 0, prevPosT;
|
||||
UInt32 prevMask = *prevMaskMix & 0x7;
|
||||
if (endPos < 5)
|
||||
return 0;
|
||||
nowPos += 5;
|
||||
prevPosT = (SizeT)0 - 1;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
Byte *p = buffer + bufferPos;
|
||||
Byte *limit = buffer + endPos - 4;
|
||||
for (; p < limit; p++)
|
||||
if ((*p & 0xFE) == 0xE8)
|
||||
break;
|
||||
bufferPos = (SizeT)(p - buffer);
|
||||
if (p >= limit)
|
||||
break;
|
||||
prevPosT = bufferPos - prevPosT;
|
||||
if (prevPosT > 3)
|
||||
prevMask = 0;
|
||||
else
|
||||
{
|
||||
prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7;
|
||||
if (prevMask != 0)
|
||||
{
|
||||
Byte b = p[4 - kMaskToBitNumber[prevMask]];
|
||||
if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b))
|
||||
{
|
||||
prevPosT = bufferPos;
|
||||
prevMask = ((prevMask << 1) & 0x7) | 1;
|
||||
bufferPos++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
prevPosT = bufferPos;
|
||||
|
||||
if (Test86MSByte(p[4]))
|
||||
{
|
||||
UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
|
||||
UInt32 dest;
|
||||
for (;;)
|
||||
{
|
||||
Byte b;
|
||||
int index;
|
||||
if (encoding)
|
||||
dest = (nowPos + (UInt32)bufferPos) + src;
|
||||
else
|
||||
dest = src - (nowPos + (UInt32)bufferPos);
|
||||
if (prevMask == 0)
|
||||
break;
|
||||
index = kMaskToBitNumber[prevMask] * 8;
|
||||
b = (Byte)(dest >> (24 - index));
|
||||
if (!Test86MSByte(b))
|
||||
break;
|
||||
src = dest ^ ((1 << (32 - index)) - 1);
|
||||
}
|
||||
p[4] = (Byte)(~(((dest >> 24) & 1) - 1));
|
||||
p[3] = (Byte)(dest >> 16);
|
||||
p[2] = (Byte)(dest >> 8);
|
||||
p[1] = (Byte)dest;
|
||||
bufferPos += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevMask = ((prevMask << 1) & 0x7) | 1;
|
||||
bufferPos++;
|
||||
}
|
||||
}
|
||||
prevPosT = bufferPos - prevPosT;
|
||||
*prevMaskMix = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7));
|
||||
return bufferPos;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/* BranchX86.h */
|
||||
|
||||
#ifndef __BRANCHX86_H
|
||||
#define __BRANCHX86_H
|
||||
|
||||
#include "BranchTypes.h"
|
||||
|
||||
#define x86_Convert_Init(state) { state = 0; }
|
||||
|
||||
SizeT x86_Convert(Byte *buffer, SizeT endPos, UInt32 nowPos, UInt32 *state, int encoding);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,135 @@
|
|||
/* BranchX86_2.c */
|
||||
|
||||
#include "BranchX86_2.h"
|
||||
|
||||
#include "../../Alloc.h"
|
||||
|
||||
#ifdef _LZMA_PROB32
|
||||
#define CProb UInt32
|
||||
#else
|
||||
#define CProb UInt16
|
||||
#endif
|
||||
|
||||
#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80)
|
||||
#define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1))
|
||||
|
||||
#define kNumTopBits 24
|
||||
#define kTopValue ((UInt32)1 << kNumTopBits)
|
||||
|
||||
#define kNumBitModelTotalBits 11
|
||||
#define kBitModelTotal (1 << kNumBitModelTotalBits)
|
||||
#define kNumMoveBits 5
|
||||
|
||||
#define RC_READ_BYTE (*Buffer++)
|
||||
|
||||
#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
|
||||
{ int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
|
||||
|
||||
#define RC_TEST { if (Buffer == BufferLim) return BCJ2_RESULT_DATA_ERROR; }
|
||||
|
||||
#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
|
||||
|
||||
#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
|
||||
|
||||
#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
|
||||
#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
|
||||
#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
|
||||
/* #define UpdateBit0(p) Range = bound; *(p) = (CProb)(*(p) + ((kBitModelTotal - *(p)) >> kNumMoveBits)); */
|
||||
/* #define UpdateBit1(p) Range -= bound; Code -= bound; *(p) = (CProb)(*(p) - (*(p) >> kNumMoveBits)); */
|
||||
|
||||
int x86_2_Decode(
|
||||
const Byte *buf0, SizeT size0,
|
||||
const Byte *buf1, SizeT size1,
|
||||
const Byte *buf2, SizeT size2,
|
||||
const Byte *buf3, SizeT size3,
|
||||
Byte *outBuf, SizeT outSize)
|
||||
{
|
||||
CProb p[256 + 2];
|
||||
SizeT inPos = 0, outPos = 0;
|
||||
|
||||
const Byte *Buffer, *BufferLim;
|
||||
UInt32 Range, Code;
|
||||
Byte prevByte = 0;
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(p) / sizeof(p[0]); i++)
|
||||
p[i] = kBitModelTotal >> 1;
|
||||
RC_INIT(buf3, size3);
|
||||
|
||||
if (outSize == 0)
|
||||
return BCJ2_RESULT_OK;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Byte b;
|
||||
CProb *prob;
|
||||
UInt32 bound;
|
||||
|
||||
SizeT limit = size0 - inPos;
|
||||
if (outSize - outPos < limit)
|
||||
limit = outSize - outPos;
|
||||
while (limit != 0)
|
||||
{
|
||||
Byte b = buf0[inPos];
|
||||
outBuf[outPos++] = b;
|
||||
if (IsJ(prevByte, b))
|
||||
break;
|
||||
inPos++;
|
||||
prevByte = b;
|
||||
limit--;
|
||||
}
|
||||
|
||||
if (limit == 0 || outPos == outSize)
|
||||
break;
|
||||
|
||||
b = buf0[inPos++];
|
||||
|
||||
if (b == 0xE8)
|
||||
prob = p + prevByte;
|
||||
else if (b == 0xE9)
|
||||
prob = p + 256;
|
||||
else
|
||||
prob = p + 257;
|
||||
|
||||
IfBit0(prob)
|
||||
{
|
||||
UpdateBit0(prob)
|
||||
prevByte = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt32 dest;
|
||||
const Byte *v;
|
||||
UpdateBit1(prob)
|
||||
if (b == 0xE8)
|
||||
{
|
||||
v = buf1;
|
||||
if (size1 < 4)
|
||||
return BCJ2_RESULT_DATA_ERROR;
|
||||
buf1 += 4;
|
||||
size1 -= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = buf2;
|
||||
if (size2 < 4)
|
||||
return BCJ2_RESULT_DATA_ERROR;
|
||||
buf2 += 4;
|
||||
size2 -= 4;
|
||||
}
|
||||
dest = (((UInt32)v[0] << 24) | ((UInt32)v[1] << 16) |
|
||||
((UInt32)v[2] << 8) | ((UInt32)v[3])) - ((UInt32)outPos + 4);
|
||||
outBuf[outPos++] = (Byte)dest;
|
||||
if (outPos == outSize)
|
||||
break;
|
||||
outBuf[outPos++] = (Byte)(dest >> 8);
|
||||
if (outPos == outSize)
|
||||
break;
|
||||
outBuf[outPos++] = (Byte)(dest >> 16);
|
||||
if (outPos == outSize)
|
||||
break;
|
||||
outBuf[outPos++] = prevByte = (Byte)(dest >> 24);
|
||||
}
|
||||
}
|
||||
return (outPos == outSize) ? BCJ2_RESULT_OK : BCJ2_RESULT_DATA_ERROR;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* BranchX86_2.h */
|
||||
|
||||
#ifndef __BRANCHX86_2_H
|
||||
#define __BRANCHX86_2_H
|
||||
|
||||
#include "BranchTypes.h"
|
||||
|
||||
#define BCJ2_RESULT_OK 0
|
||||
#define BCJ2_RESULT_DATA_ERROR 1
|
||||
|
||||
/*
|
||||
Conditions:
|
||||
outSize <= FullOutputSize,
|
||||
where FullOutputSize is full size of output stream of x86_2 filter.
|
||||
|
||||
If buf0 overlaps outBuf, there are two required conditions:
|
||||
1) (buf0 >= outBuf)
|
||||
2) (buf0 + size0 >= outBuf + FullOutputSize).
|
||||
*/
|
||||
|
||||
int x86_2_Decode(
|
||||
const Byte *buf0, SizeT size0,
|
||||
const Byte *buf1, SizeT size1,
|
||||
const Byte *buf2, SizeT size2,
|
||||
const Byte *buf3, SizeT size3,
|
||||
Byte *outBuf, SizeT outSize);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,584 @@
|
|||
/*
|
||||
LzmaDecode.c
|
||||
LZMA Decoder (optimized for Speed version)
|
||||
|
||||
LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
|
||||
http://www.7-zip.org/
|
||||
|
||||
LZMA SDK is licensed under two licenses:
|
||||
1) GNU Lesser General Public License (GNU LGPL)
|
||||
2) Common Public License (CPL)
|
||||
It means that you can select one of these two licenses and
|
||||
follow rules of that license.
|
||||
|
||||
SPECIAL EXCEPTION:
|
||||
Igor Pavlov, as the author of this Code, expressly permits you to
|
||||
statically or dynamically link your Code (or bind by name) to the
|
||||
interfaces of this file without subjecting your linked Code to the
|
||||
terms of the CPL or GNU LGPL. Any modifications or additions
|
||||
to this file, however, are subject to the LGPL or CPL terms.
|
||||
*/
|
||||
|
||||
#include "LzmaDecode.h"
|
||||
|
||||
#define kNumTopBits 24
|
||||
#define kTopValue ((UInt32)1 << kNumTopBits)
|
||||
|
||||
#define kNumBitModelTotalBits 11
|
||||
#define kBitModelTotal (1 << kNumBitModelTotalBits)
|
||||
#define kNumMoveBits 5
|
||||
|
||||
#define RC_READ_BYTE (*Buffer++)
|
||||
|
||||
#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
|
||||
{ int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
|
||||
#define RC_TEST { if (Buffer == BufferLim) \
|
||||
{ SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
|
||||
BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
|
||||
|
||||
#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
|
||||
|
||||
#else
|
||||
|
||||
#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
|
||||
|
||||
#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
|
||||
|
||||
#endif
|
||||
|
||||
#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
|
||||
|
||||
#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
|
||||
#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
|
||||
#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
|
||||
|
||||
#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
|
||||
{ UpdateBit0(p); mi <<= 1; A0; } else \
|
||||
{ UpdateBit1(p); mi = (mi + mi) + 1; A1; }
|
||||
|
||||
#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
|
||||
|
||||
#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
|
||||
{ int i = numLevels; res = 1; \
|
||||
do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
|
||||
res -= (1 << numLevels); }
|
||||
|
||||
|
||||
#define kNumPosBitsMax 4
|
||||
#define kNumPosStatesMax (1 << kNumPosBitsMax)
|
||||
|
||||
#define kLenNumLowBits 3
|
||||
#define kLenNumLowSymbols (1 << kLenNumLowBits)
|
||||
#define kLenNumMidBits 3
|
||||
#define kLenNumMidSymbols (1 << kLenNumMidBits)
|
||||
#define kLenNumHighBits 8
|
||||
#define kLenNumHighSymbols (1 << kLenNumHighBits)
|
||||
|
||||
#define LenChoice 0
|
||||
#define LenChoice2 (LenChoice + 1)
|
||||
#define LenLow (LenChoice2 + 1)
|
||||
#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
|
||||
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
|
||||
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
|
||||
|
||||
|
||||
#define kNumStates 12
|
||||
#define kNumLitStates 7
|
||||
|
||||
#define kStartPosModelIndex 4
|
||||
#define kEndPosModelIndex 14
|
||||
#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
|
||||
|
||||
#define kNumPosSlotBits 6
|
||||
#define kNumLenToPosStates 4
|
||||
|
||||
#define kNumAlignBits 4
|
||||
#define kAlignTableSize (1 << kNumAlignBits)
|
||||
|
||||
#define kMatchMinLen 2
|
||||
|
||||
#define IsMatch 0
|
||||
#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
|
||||
#define IsRepG0 (IsRep + kNumStates)
|
||||
#define IsRepG1 (IsRepG0 + kNumStates)
|
||||
#define IsRepG2 (IsRepG1 + kNumStates)
|
||||
#define IsRep0Long (IsRepG2 + kNumStates)
|
||||
#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
|
||||
#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
|
||||
#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
|
||||
#define LenCoder (Align + kAlignTableSize)
|
||||
#define RepLenCoder (LenCoder + kNumLenProbs)
|
||||
#define Literal (RepLenCoder + kNumLenProbs)
|
||||
|
||||
#if Literal != LZMA_BASE_SIZE
|
||||
StopCompilingDueBUG
|
||||
#endif
|
||||
|
||||
int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
|
||||
{
|
||||
unsigned char prop0;
|
||||
if (size < LZMA_PROPERTIES_SIZE)
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
prop0 = propsData[0];
|
||||
if (prop0 >= (9 * 5 * 5))
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
{
|
||||
for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5)) ;
|
||||
for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9) ;
|
||||
propsRes->lc = prop0;
|
||||
/*
|
||||
unsigned char remainder = (unsigned char)(prop0 / 9);
|
||||
propsRes->lc = prop0 % 9;
|
||||
propsRes->pb = remainder / 5;
|
||||
propsRes->lp = remainder % 5;
|
||||
*/
|
||||
}
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
{
|
||||
int i;
|
||||
propsRes->DictionarySize = 0;
|
||||
for (i = 0; i < 4; i++)
|
||||
propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
|
||||
if (propsRes->DictionarySize == 0)
|
||||
propsRes->DictionarySize = 1;
|
||||
}
|
||||
#endif
|
||||
return LZMA_RESULT_OK;
|
||||
}
|
||||
|
||||
#define kLzmaStreamWasFinishedId (-1)
|
||||
|
||||
int LzmaDecode(CLzmaDecoderState *vs,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *InCallback,
|
||||
#else
|
||||
const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
|
||||
#endif
|
||||
unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
|
||||
{
|
||||
CProb *p = vs->Probs;
|
||||
SizeT nowPos = 0;
|
||||
Byte previousByte = 0;
|
||||
UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
|
||||
UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
|
||||
int lc = vs->Properties.lc;
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
|
||||
UInt32 Range = vs->Range;
|
||||
UInt32 Code = vs->Code;
|
||||
#ifdef _LZMA_IN_CB
|
||||
const Byte *Buffer = vs->Buffer;
|
||||
const Byte *BufferLim = vs->BufferLim;
|
||||
#else
|
||||
const Byte *Buffer = inStream;
|
||||
const Byte *BufferLim = inStream + inSize;
|
||||
#endif
|
||||
int state = vs->State;
|
||||
UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
|
||||
int len = vs->RemainLen;
|
||||
UInt32 globalPos = vs->GlobalPos;
|
||||
UInt32 distanceLimit = vs->DistanceLimit;
|
||||
|
||||
Byte *dictionary = vs->Dictionary;
|
||||
UInt32 dictionarySize = vs->Properties.DictionarySize;
|
||||
UInt32 dictionaryPos = vs->DictionaryPos;
|
||||
|
||||
Byte tempDictionary[4];
|
||||
|
||||
#ifndef _LZMA_IN_CB
|
||||
*inSizeProcessed = 0;
|
||||
#endif
|
||||
*outSizeProcessed = 0;
|
||||
if (len == kLzmaStreamWasFinishedId)
|
||||
return LZMA_RESULT_OK;
|
||||
|
||||
if (dictionarySize == 0)
|
||||
{
|
||||
dictionary = tempDictionary;
|
||||
dictionarySize = 1;
|
||||
tempDictionary[0] = vs->TempDictionary[0];
|
||||
}
|
||||
|
||||
if (len == kLzmaNeedInitId)
|
||||
{
|
||||
{
|
||||
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
|
||||
UInt32 i;
|
||||
for (i = 0; i < numProbs; i++)
|
||||
p[i] = kBitModelTotal >> 1;
|
||||
rep0 = rep1 = rep2 = rep3 = 1;
|
||||
state = 0;
|
||||
globalPos = 0;
|
||||
distanceLimit = 0;
|
||||
dictionaryPos = 0;
|
||||
dictionary[dictionarySize - 1] = 0;
|
||||
#ifdef _LZMA_IN_CB
|
||||
RC_INIT;
|
||||
#else
|
||||
RC_INIT(inStream, inSize);
|
||||
#endif
|
||||
}
|
||||
len = 0;
|
||||
}
|
||||
while(len != 0 && nowPos < outSize)
|
||||
{
|
||||
UInt32 pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
len--;
|
||||
}
|
||||
if (dictionaryPos == 0)
|
||||
previousByte = dictionary[dictionarySize - 1];
|
||||
else
|
||||
previousByte = dictionary[dictionaryPos - 1];
|
||||
|
||||
#else /* if !_LZMA_OUT_READ */
|
||||
|
||||
int state = 0;
|
||||
UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
|
||||
int len = 0;
|
||||
const Byte *Buffer;
|
||||
const Byte *BufferLim;
|
||||
UInt32 Range;
|
||||
UInt32 Code;
|
||||
|
||||
#ifndef _LZMA_IN_CB
|
||||
*inSizeProcessed = 0;
|
||||
#endif
|
||||
*outSizeProcessed = 0;
|
||||
|
||||
{
|
||||
UInt32 i;
|
||||
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
|
||||
for (i = 0; i < numProbs; i++)
|
||||
p[i] = kBitModelTotal >> 1;
|
||||
}
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
RC_INIT;
|
||||
#else
|
||||
RC_INIT(inStream, inSize);
|
||||
#endif
|
||||
|
||||
#endif /* _LZMA_OUT_READ */
|
||||
|
||||
while(nowPos < outSize)
|
||||
{
|
||||
CProb *prob;
|
||||
UInt32 bound;
|
||||
int posState = (int)(
|
||||
(nowPos
|
||||
#ifdef _LZMA_OUT_READ
|
||||
+ globalPos
|
||||
#endif
|
||||
)
|
||||
& posStateMask);
|
||||
|
||||
prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
|
||||
IfBit0(prob)
|
||||
{
|
||||
int symbol = 1;
|
||||
UpdateBit0(prob)
|
||||
prob = p + Literal + (LZMA_LIT_SIZE *
|
||||
(((
|
||||
(nowPos
|
||||
#ifdef _LZMA_OUT_READ
|
||||
+ globalPos
|
||||
#endif
|
||||
)
|
||||
& literalPosMask) << lc) + (previousByte >> (8 - lc))));
|
||||
|
||||
if (state >= kNumLitStates)
|
||||
{
|
||||
int matchByte;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
matchByte = dictionary[pos];
|
||||
#else
|
||||
matchByte = outStream[nowPos - rep0];
|
||||
#endif
|
||||
do
|
||||
{
|
||||
int bit;
|
||||
CProb *probLit;
|
||||
matchByte <<= 1;
|
||||
bit = (matchByte & 0x100);
|
||||
probLit = prob + 0x100 + bit + symbol;
|
||||
RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
|
||||
}
|
||||
while (symbol < 0x100);
|
||||
}
|
||||
while (symbol < 0x100)
|
||||
{
|
||||
CProb *probLit = prob + symbol;
|
||||
RC_GET_BIT(probLit, symbol)
|
||||
}
|
||||
previousByte = (Byte)symbol;
|
||||
|
||||
outStream[nowPos++] = previousByte;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
if (distanceLimit < dictionarySize)
|
||||
distanceLimit++;
|
||||
|
||||
dictionary[dictionaryPos] = previousByte;
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
#endif
|
||||
if (state < 4) state = 0;
|
||||
else if (state < 10) state -= 3;
|
||||
else state -= 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRep + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
UpdateBit0(prob);
|
||||
rep3 = rep2;
|
||||
rep2 = rep1;
|
||||
rep1 = rep0;
|
||||
state = state < kNumLitStates ? 0 : 3;
|
||||
prob = p + LenCoder;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRepG0 + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
UpdateBit0(prob);
|
||||
prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
|
||||
IfBit0(prob)
|
||||
{
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 pos;
|
||||
#endif
|
||||
UpdateBit0(prob);
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
if (distanceLimit == 0)
|
||||
#else
|
||||
if (nowPos == 0)
|
||||
#endif
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
|
||||
state = state < kNumLitStates ? 9 : 11;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
previousByte = dictionary[pos];
|
||||
dictionary[dictionaryPos] = previousByte;
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
#else
|
||||
previousByte = outStream[nowPos - rep0];
|
||||
#endif
|
||||
outStream[nowPos++] = previousByte;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
if (distanceLimit < dictionarySize)
|
||||
distanceLimit++;
|
||||
#endif
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(prob);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt32 distance;
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRepG1 + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
UpdateBit0(prob);
|
||||
distance = rep1;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRepG2 + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
UpdateBit0(prob);
|
||||
distance = rep2;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(prob);
|
||||
distance = rep3;
|
||||
rep3 = rep2;
|
||||
}
|
||||
rep2 = rep1;
|
||||
}
|
||||
rep1 = rep0;
|
||||
rep0 = distance;
|
||||
}
|
||||
state = state < kNumLitStates ? 8 : 11;
|
||||
prob = p + RepLenCoder;
|
||||
}
|
||||
{
|
||||
int numBits, offset;
|
||||
CProb *probLen = prob + LenChoice;
|
||||
IfBit0(probLen)
|
||||
{
|
||||
UpdateBit0(probLen);
|
||||
probLen = prob + LenLow + (posState << kLenNumLowBits);
|
||||
offset = 0;
|
||||
numBits = kLenNumLowBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(probLen);
|
||||
probLen = prob + LenChoice2;
|
||||
IfBit0(probLen)
|
||||
{
|
||||
UpdateBit0(probLen);
|
||||
probLen = prob + LenMid + (posState << kLenNumMidBits);
|
||||
offset = kLenNumLowSymbols;
|
||||
numBits = kLenNumMidBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBit1(probLen);
|
||||
probLen = prob + LenHigh;
|
||||
offset = kLenNumLowSymbols + kLenNumMidSymbols;
|
||||
numBits = kLenNumHighBits;
|
||||
}
|
||||
}
|
||||
RangeDecoderBitTreeDecode(probLen, numBits, len);
|
||||
len += offset;
|
||||
}
|
||||
|
||||
if (state < 4)
|
||||
{
|
||||
int posSlot;
|
||||
state += kNumLitStates;
|
||||
prob = p + PosSlot +
|
||||
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
|
||||
kNumPosSlotBits);
|
||||
RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
|
||||
if (posSlot >= kStartPosModelIndex)
|
||||
{
|
||||
int numDirectBits = ((posSlot >> 1) - 1);
|
||||
rep0 = (2 | ((UInt32)posSlot & 1));
|
||||
if (posSlot < kEndPosModelIndex)
|
||||
{
|
||||
rep0 <<= numDirectBits;
|
||||
prob = p + SpecPos + rep0 - posSlot - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
numDirectBits -= kNumAlignBits;
|
||||
do
|
||||
{
|
||||
RC_NORMALIZE
|
||||
Range >>= 1;
|
||||
rep0 <<= 1;
|
||||
if (Code >= Range)
|
||||
{
|
||||
Code -= Range;
|
||||
rep0 |= 1;
|
||||
}
|
||||
}
|
||||
while (--numDirectBits != 0);
|
||||
prob = p + Align;
|
||||
rep0 <<= kNumAlignBits;
|
||||
numDirectBits = kNumAlignBits;
|
||||
}
|
||||
{
|
||||
int i = 1;
|
||||
int mi = 1;
|
||||
do
|
||||
{
|
||||
CProb *prob3 = prob + mi;
|
||||
RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
|
||||
i <<= 1;
|
||||
}
|
||||
while(--numDirectBits != 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
rep0 = posSlot;
|
||||
if (++rep0 == (UInt32)(0))
|
||||
{
|
||||
/* it's for stream version */
|
||||
len = kLzmaStreamWasFinishedId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
len += kMatchMinLen;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
if (rep0 > distanceLimit)
|
||||
#else
|
||||
if (rep0 > nowPos)
|
||||
#endif
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
if (dictionarySize - distanceLimit > (UInt32)len)
|
||||
distanceLimit += len;
|
||||
else
|
||||
distanceLimit = dictionarySize;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
previousByte = dictionary[pos];
|
||||
dictionary[dictionaryPos] = previousByte;
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
#else
|
||||
previousByte = outStream[nowPos - rep0];
|
||||
#endif
|
||||
len--;
|
||||
outStream[nowPos++] = previousByte;
|
||||
}
|
||||
while(len != 0 && nowPos < outSize);
|
||||
}
|
||||
}
|
||||
RC_NORMALIZE;
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
vs->Range = Range;
|
||||
vs->Code = Code;
|
||||
vs->DictionaryPos = dictionaryPos;
|
||||
vs->GlobalPos = globalPos + (UInt32)nowPos;
|
||||
vs->DistanceLimit = distanceLimit;
|
||||
vs->Reps[0] = rep0;
|
||||
vs->Reps[1] = rep1;
|
||||
vs->Reps[2] = rep2;
|
||||
vs->Reps[3] = rep3;
|
||||
vs->State = state;
|
||||
vs->RemainLen = len;
|
||||
vs->TempDictionary[0] = tempDictionary[0];
|
||||
#endif
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
vs->Buffer = Buffer;
|
||||
vs->BufferLim = BufferLim;
|
||||
#else
|
||||
*inSizeProcessed = (SizeT)(Buffer - inStream);
|
||||
#endif
|
||||
*outSizeProcessed = nowPos;
|
||||
return LZMA_RESULT_OK;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
LzmaDecode.h
|
||||
LZMA Decoder interface
|
||||
|
||||
LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
|
||||
http://www.7-zip.org/
|
||||
|
||||
LZMA SDK is licensed under two licenses:
|
||||
1) GNU Lesser General Public License (GNU LGPL)
|
||||
2) Common Public License (CPL)
|
||||
It means that you can select one of these two licenses and
|
||||
follow rules of that license.
|
||||
|
||||
SPECIAL EXCEPTION:
|
||||
Igor Pavlov, as the author of this code, expressly permits you to
|
||||
statically or dynamically link your code (or bind by name) to the
|
||||
interfaces of this file without subjecting your linked code to the
|
||||
terms of the CPL or GNU LGPL. Any modifications or additions
|
||||
to this file, however, are subject to the LGPL or CPL terms.
|
||||
*/
|
||||
|
||||
#ifndef __LZMADECODE_H
|
||||
#define __LZMADECODE_H
|
||||
|
||||
#include "LzmaTypes.h"
|
||||
|
||||
#define _LZMA_IN_CB
|
||||
/* Use callback for input data */
|
||||
|
||||
/* #define _LZMA_OUT_READ */
|
||||
/* Use read function for output data */
|
||||
|
||||
/* #define _LZMA_PROB32 */
|
||||
/* It can increase speed on some 32-bit CPUs,
|
||||
but memory usage will be doubled in that case */
|
||||
|
||||
/* #define _LZMA_LOC_OPT */
|
||||
/* Enable local speed optimizations inside code */
|
||||
|
||||
#ifdef _LZMA_PROB32
|
||||
#define CProb UInt32
|
||||
#else
|
||||
#define CProb UInt16
|
||||
#endif
|
||||
|
||||
#define LZMA_RESULT_OK 0
|
||||
#define LZMA_RESULT_DATA_ERROR 1
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
typedef struct _ILzmaInCallback
|
||||
{
|
||||
int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
|
||||
} ILzmaInCallback;
|
||||
#endif
|
||||
|
||||
#define LZMA_BASE_SIZE 1846
|
||||
#define LZMA_LIT_SIZE 768
|
||||
|
||||
#define LZMA_PROPERTIES_SIZE 5
|
||||
|
||||
typedef struct _CLzmaProperties
|
||||
{
|
||||
int lc;
|
||||
int lp;
|
||||
int pb;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 DictionarySize;
|
||||
#endif
|
||||
}CLzmaProperties;
|
||||
|
||||
int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
|
||||
|
||||
#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
|
||||
|
||||
#define kLzmaNeedInitId (-2)
|
||||
|
||||
typedef struct _CLzmaDecoderState
|
||||
{
|
||||
CLzmaProperties Properties;
|
||||
CProb *Probs;
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
const unsigned char *Buffer;
|
||||
const unsigned char *BufferLim;
|
||||
#endif
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
unsigned char *Dictionary;
|
||||
UInt32 Range;
|
||||
UInt32 Code;
|
||||
UInt32 DictionaryPos;
|
||||
UInt32 GlobalPos;
|
||||
UInt32 DistanceLimit;
|
||||
UInt32 Reps[4];
|
||||
int State;
|
||||
int RemainLen;
|
||||
unsigned char TempDictionary[4];
|
||||
#endif
|
||||
} CLzmaDecoderState;
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
|
||||
#endif
|
||||
|
||||
int LzmaDecode(CLzmaDecoderState *vs,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *inCallback,
|
||||
#else
|
||||
const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
|
||||
#endif
|
||||
unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
LzmaTypes.h
|
||||
|
||||
Types for LZMA Decoder
|
||||
|
||||
This file written and distributed to public domain by Igor Pavlov.
|
||||
This file is part of LZMA SDK 4.40 (2006-05-01)
|
||||
*/
|
||||
|
||||
#ifndef __LZMATYPES_H
|
||||
#define __LZMATYPES_H
|
||||
|
||||
#ifndef _7ZIP_BYTE_DEFINED
|
||||
#define _7ZIP_BYTE_DEFINED
|
||||
typedef unsigned char Byte;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT16_DEFINED
|
||||
#define _7ZIP_UINT16_DEFINED
|
||||
typedef unsigned short UInt16;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT32_DEFINED
|
||||
#define _7ZIP_UINT32_DEFINED
|
||||
#ifdef _LZMA_UINT32_IS_ULONG
|
||||
typedef unsigned long UInt32;
|
||||
#else
|
||||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* #define _LZMA_NO_SYSTEM_SIZE_T */
|
||||
/* You can use it, if you don't want <stddef.h> */
|
||||
|
||||
#ifndef _7ZIP_SIZET_DEFINED
|
||||
#define _7ZIP_SIZET_DEFINED
|
||||
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
||||
typedef UInt32 SizeT;
|
||||
#else
|
||||
#include <stddef.h>
|
||||
typedef size_t SizeT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,100 @@
|
|||
/* 7zTypes.h */
|
||||
|
||||
#ifndef __C_TYPES_H
|
||||
#define __C_TYPES_H
|
||||
|
||||
#ifndef _7ZIP_BYTE_DEFINED
|
||||
#define _7ZIP_BYTE_DEFINED
|
||||
typedef unsigned char Byte;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT16_DEFINED
|
||||
#define _7ZIP_UINT16_DEFINED
|
||||
typedef unsigned short UInt16;
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_UINT32_DEFINED
|
||||
#define _7ZIP_UINT32_DEFINED
|
||||
#ifdef _LZMA_UINT32_IS_ULONG
|
||||
typedef unsigned long UInt32;
|
||||
#else
|
||||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _7ZIP_INT32_DEFINED
|
||||
#define _7ZIP_INT32_DEFINED
|
||||
#ifdef _LZMA_INT32_IS_ULONG
|
||||
typedef long Int32;
|
||||
#else
|
||||
typedef int Int32;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* #define _SZ_NO_INT_64 */
|
||||
/* define it your compiler doesn't support long long int */
|
||||
|
||||
#ifndef _7ZIP_UINT64_DEFINED
|
||||
#define _7ZIP_UINT64_DEFINED
|
||||
#ifdef _SZ_NO_INT_64
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else
|
||||
typedef unsigned long long int UInt64;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* #define _SZ_FILE_SIZE_32 */
|
||||
/* You can define _SZ_FILE_SIZE_32, if you don't need support for files larger than 4 GB*/
|
||||
|
||||
#ifndef CFileSize
|
||||
#ifdef _SZ_FILE_SIZE_32
|
||||
typedef UInt32 CFileSize;
|
||||
#else
|
||||
typedef UInt64 CFileSize;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SZ_RESULT int
|
||||
|
||||
typedef int HRes;
|
||||
#define RES_OK (0)
|
||||
|
||||
#define SZ_OK (0)
|
||||
#define SZE_DATA_ERROR (1)
|
||||
#define SZE_CRC_ERROR (3)
|
||||
#define SZE_ARCHIVE_ERROR (6)
|
||||
|
||||
#define SZE_OUTOFMEMORY (0x8007000EL)
|
||||
#define SZE_NOTIMPL (0x80004001L)
|
||||
#define SZE_FAIL (0x80004005L)
|
||||
#define SZE_INVALIDARG (0x80070057L)
|
||||
|
||||
|
||||
#ifndef RINOK
|
||||
#define RINOK(x) { HRes __result_ = (x); if(__result_ != 0) return __result_; }
|
||||
#endif
|
||||
|
||||
typedef int Bool;
|
||||
#define True 1
|
||||
#define False 0
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define StdCall __stdcall
|
||||
#else
|
||||
#define StdCall
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#define MY_FAST_CALL __declspec(noinline) __fastcall
|
||||
#elif defined( _MSC_VER)
|
||||
#define MY_FAST_CALL __fastcall
|
||||
#else
|
||||
#define MY_FAST_CALL
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,19 @@
|
|||
Changes to 7z_C source
|
||||
----------------------
|
||||
I made several minor changes:
|
||||
|
||||
* Enabled _LZMA_IN_CB in LzmaDecoer.h and fixed other files that depend
|
||||
on this setting to properly #include this file
|
||||
|
||||
* Fixed several memory free functions to not access NULL when cleaning
|
||||
up after a failed allocation.
|
||||
|
||||
* Made private functions static.
|
||||
|
||||
* Fixed SzArchiveOpen to properly report error when header can't be
|
||||
read.
|
||||
|
||||
* Fixed glaring conflicts between LzmaTypes.h and 7zTypes.h.
|
||||
|
||||
--
|
||||
Shay Green <gblargg@gmail.com>
|
|
@ -0,0 +1,663 @@
|
|||
LZMA SDK 4.57
|
||||
-------------
|
||||
|
||||
LZMA SDK Copyright (C) 1999-2007 Igor Pavlov
|
||||
|
||||
LZMA SDK provides the documentation, samples, header files, libraries,
|
||||
and tools you need to develop applications that use LZMA compression.
|
||||
|
||||
LZMA is default and general compression method of 7z format
|
||||
in 7-Zip compression program (www.7-zip.org). LZMA provides high
|
||||
compression ratio and very fast decompression.
|
||||
|
||||
LZMA is an improved version of famous LZ77 compression algorithm.
|
||||
It was improved in way of maximum increasing of compression ratio,
|
||||
keeping high decompression speed and low memory requirements for
|
||||
decompressing.
|
||||
|
||||
|
||||
|
||||
LICENSE
|
||||
-------
|
||||
|
||||
LZMA SDK is available under any of the following licenses:
|
||||
|
||||
1) GNU Lesser General Public License (GNU LGPL)
|
||||
2) Common Public License (CPL)
|
||||
3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
|
||||
4) Proprietary license
|
||||
|
||||
It means that you can select one of these four options and follow rules of that license.
|
||||
|
||||
|
||||
1,2) GNU LGPL and CPL licenses are pretty similar and both these
|
||||
licenses are classified as
|
||||
- "Free software licenses" at http://www.gnu.org/
|
||||
- "OSI-approved" at http://www.opensource.org/
|
||||
|
||||
|
||||
3) SPECIAL EXCEPTION
|
||||
|
||||
Igor Pavlov, as the author of this code, expressly permits you
|
||||
to statically or dynamically link your code (or bind by name)
|
||||
to the files from LZMA SDK without subjecting your linked
|
||||
code to the terms of the CPL or GNU LGPL.
|
||||
Any modifications or additions to files from LZMA SDK, however,
|
||||
are subject to the GNU LGPL or CPL terms.
|
||||
|
||||
SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
|
||||
while you keep LZMA SDK code unmodified.
|
||||
|
||||
|
||||
SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits
|
||||
you to use this code under the same terms and conditions contained in the License
|
||||
Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov.
|
||||
|
||||
SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version
|
||||
of LZMA SDK as update for previous versions.
|
||||
|
||||
|
||||
SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits
|
||||
you to use code of the following files:
|
||||
BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp,
|
||||
LzmaAlone.cs, LzmaAlone.java
|
||||
as public domain code.
|
||||
|
||||
|
||||
4) Proprietary license
|
||||
|
||||
LZMA SDK also can be available under a proprietary license which
|
||||
can include:
|
||||
|
||||
1) Right to modify code without subjecting modified code to the
|
||||
terms of the CPL or GNU LGPL
|
||||
2) Technical support for code
|
||||
|
||||
To request such proprietary license or any additional consultations,
|
||||
send email message from that page:
|
||||
http://www.7-zip.org/support.html
|
||||
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
You should have received a copy of the Common Public License
|
||||
along with this library.
|
||||
|
||||
|
||||
LZMA SDK Contents
|
||||
-----------------
|
||||
|
||||
LZMA SDK includes:
|
||||
|
||||
- C++ source code of LZMA compressing and decompressing
|
||||
- ANSI-C compatible source code for LZMA decompressing
|
||||
- C# source code for LZMA compressing and decompressing
|
||||
- Java source code for LZMA compressing and decompressing
|
||||
- Compiled file->file LZMA compressing/decompressing program for Windows system
|
||||
|
||||
ANSI-C LZMA decompression code was ported from original C++ sources to C.
|
||||
Also it was simplified and optimized for code size.
|
||||
But it is fully compatible with LZMA from 7-Zip.
|
||||
|
||||
|
||||
UNIX/Linux version
|
||||
------------------
|
||||
To compile C++ version of file->file LZMA, go to directory
|
||||
C/7zip/Compress/LZMA_Alone
|
||||
and type "make" or "make clean all" to recompile all.
|
||||
|
||||
In some UNIX/Linux versions you must compile LZMA with static libraries.
|
||||
To compile with static libraries, change string in makefile
|
||||
LIB = -lm
|
||||
to string
|
||||
LIB = -lm -static
|
||||
|
||||
|
||||
Files
|
||||
---------------------
|
||||
C - C source code
|
||||
CPP - CPP source code
|
||||
CS - C# source code
|
||||
Java - Java source code
|
||||
lzma.txt - LZMA SDK description (this file)
|
||||
7zFormat.txt - 7z Format description
|
||||
7zC.txt - 7z ANSI-C Decoder description (this file)
|
||||
methods.txt - Compression method IDs for .7z
|
||||
LGPL.txt - GNU Lesser General Public License
|
||||
CPL.html - Common Public License
|
||||
lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
|
||||
history.txt - history of the LZMA SDK
|
||||
|
||||
|
||||
Source code structure
|
||||
---------------------
|
||||
|
||||
C - C files
|
||||
Compress - files related to compression/decompression
|
||||
Lz - files related to LZ (Lempel-Ziv) compression algorithm
|
||||
Lzma - ANSI-C compatible LZMA decompressor
|
||||
|
||||
LzmaDecode.h - interface for LZMA decoding on ANSI-C
|
||||
LzmaDecode.c - LZMA decoding on ANSI-C (new fastest version)
|
||||
LzmaDecodeSize.c - LZMA decoding on ANSI-C (old size-optimized version)
|
||||
LzmaTest.c - test application that decodes LZMA encoded file
|
||||
LzmaTypes.h - basic types for LZMA Decoder
|
||||
LzmaStateDecode.h - interface for LZMA decoding (State version)
|
||||
LzmaStateDecode.c - LZMA decoding on ANSI-C (State version)
|
||||
LzmaStateTest.c - test application (State version)
|
||||
|
||||
Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
|
||||
|
||||
Archive - files related to archiving
|
||||
7z_C - 7z ANSI-C Decoder
|
||||
|
||||
|
||||
CPP -- CPP files
|
||||
|
||||
Common - common files for C++ projects
|
||||
Windows - common files for Windows related code
|
||||
7zip - files related to 7-Zip Project
|
||||
|
||||
Common - common files for 7-Zip
|
||||
|
||||
Compress - files related to compression/decompression
|
||||
|
||||
LZ - files related to LZ (Lempel-Ziv) compression algorithm
|
||||
|
||||
Copy - Copy coder
|
||||
RangeCoder - Range Coder (special code of compression/decompression)
|
||||
LZMA - LZMA compression/decompression on C++
|
||||
LZMA_Alone - file->file LZMA compression/decompression
|
||||
|
||||
Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
|
||||
|
||||
Archive - files related to archiving
|
||||
|
||||
Common - common files for archive handling
|
||||
7z - 7z C++ Encoder/Decoder
|
||||
|
||||
Bundles - Modules that are bundles of other modules
|
||||
|
||||
Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
|
||||
Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
|
||||
Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
|
||||
|
||||
UI - User Interface files
|
||||
|
||||
Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll
|
||||
Common - Common UI files
|
||||
Console - Code for console archiver
|
||||
|
||||
|
||||
|
||||
CS - C# files
|
||||
7zip
|
||||
Common - some common files for 7-Zip
|
||||
Compress - files related to compression/decompression
|
||||
LZ - files related to LZ (Lempel-Ziv) compression algorithm
|
||||
LZMA - LZMA compression/decompression
|
||||
LzmaAlone - file->file LZMA compression/decompression
|
||||
RangeCoder - Range Coder (special code of compression/decompression)
|
||||
|
||||
Java - Java files
|
||||
SevenZip
|
||||
Compression - files related to compression/decompression
|
||||
LZ - files related to LZ (Lempel-Ziv) compression algorithm
|
||||
LZMA - LZMA compression/decompression
|
||||
RangeCoder - Range Coder (special code of compression/decompression)
|
||||
|
||||
C/C++ source code of LZMA SDK is part of 7-Zip project.
|
||||
|
||||
You can find ANSI-C LZMA decompressing code at folder
|
||||
C/7zip/Compress/Lzma
|
||||
7-Zip doesn't use that ANSI-C LZMA code and that code was developed
|
||||
specially for this SDK. And files from C/7zip/Compress/Lzma do not need
|
||||
files from other directories of SDK for compiling.
|
||||
|
||||
7-Zip source code can be downloaded from 7-Zip's SourceForge page:
|
||||
|
||||
http://sourceforge.net/projects/sevenzip/
|
||||
|
||||
|
||||
LZMA features
|
||||
-------------
|
||||
- Variable dictionary size (up to 1 GB)
|
||||
- Estimated compressing speed: about 1 MB/s on 1 GHz CPU
|
||||
- Estimated decompressing speed:
|
||||
- 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon
|
||||
- 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC
|
||||
- Small memory requirements for decompressing (8-32 KB + DictionarySize)
|
||||
- Small code size for decompressing: 2-8 KB (depending from
|
||||
speed optimizations)
|
||||
|
||||
LZMA decoder uses only integer operations and can be
|
||||
implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
|
||||
|
||||
Some critical operations that affect to speed of LZMA decompression:
|
||||
1) 32*16 bit integer multiply
|
||||
2) Misspredicted branches (penalty mostly depends from pipeline length)
|
||||
3) 32-bit shift and arithmetic operations
|
||||
|
||||
Speed of LZMA decompressing mostly depends from CPU speed.
|
||||
Memory speed has no big meaning. But if your CPU has small data cache,
|
||||
overall weight of memory speed will slightly increase.
|
||||
|
||||
|
||||
How To Use
|
||||
----------
|
||||
|
||||
Using LZMA encoder/decoder executable
|
||||
--------------------------------------
|
||||
|
||||
Usage: LZMA <e|d> inputFile outputFile [<switches>...]
|
||||
|
||||
e: encode file
|
||||
|
||||
d: decode file
|
||||
|
||||
b: Benchmark. There are two tests: compressing and decompressing
|
||||
with LZMA method. Benchmark shows rating in MIPS (million
|
||||
instructions per second). Rating value is calculated from
|
||||
measured speed and it is normalized with AMD Athlon 64 X2 CPU
|
||||
results. Also Benchmark checks possible hardware errors (RAM
|
||||
errors in most cases). Benchmark uses these settings:
|
||||
(-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you
|
||||
can change number of iterations. Example for 30 iterations:
|
||||
LZMA b 30
|
||||
Default number of iterations is 10.
|
||||
|
||||
<Switches>
|
||||
|
||||
|
||||
-a{N}: set compression mode 0 = fast, 1 = normal
|
||||
default: 1 (normal)
|
||||
|
||||
d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB)
|
||||
The maximum value for dictionary size is 1 GB = 2^30 bytes.
|
||||
Dictionary size is calculated as DictionarySize = 2^N bytes.
|
||||
For decompressing file compressed by LZMA method with dictionary
|
||||
size D = 2^N you need about D bytes of memory (RAM).
|
||||
|
||||
-fb{N}: set number of fast bytes - [5, 273], default: 128
|
||||
Usually big number gives a little bit better compression ratio
|
||||
and slower compression process.
|
||||
|
||||
-lc{N}: set number of literal context bits - [0, 8], default: 3
|
||||
Sometimes lc=4 gives gain for big files.
|
||||
|
||||
-lp{N}: set number of literal pos bits - [0, 4], default: 0
|
||||
lp switch is intended for periodical data when period is
|
||||
equal 2^N. For example, for 32-bit (4 bytes)
|
||||
periodical data you can use lp=2. Often it's better to set lc0,
|
||||
if you change lp switch.
|
||||
|
||||
-pb{N}: set number of pos bits - [0, 4], default: 2
|
||||
pb switch is intended for periodical data
|
||||
when period is equal 2^N.
|
||||
|
||||
-mf{MF_ID}: set Match Finder. Default: bt4.
|
||||
Algorithms from hc* group doesn't provide good compression
|
||||
ratio, but they often works pretty fast in combination with
|
||||
fast mode (-a0).
|
||||
|
||||
Memory requirements depend from dictionary size
|
||||
(parameter "d" in table below).
|
||||
|
||||
MF_ID Memory Description
|
||||
|
||||
bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing.
|
||||
bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing.
|
||||
bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing.
|
||||
hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing.
|
||||
|
||||
-eos: write End Of Stream marker. By default LZMA doesn't write
|
||||
eos marker, since LZMA decoder knows uncompressed size
|
||||
stored in .lzma file header.
|
||||
|
||||
-si: Read data from stdin (it will write End Of Stream marker).
|
||||
-so: Write data to stdout
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
1) LZMA e file.bin file.lzma -d16 -lc0
|
||||
|
||||
compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)
|
||||
and 0 literal context bits. -lc0 allows to reduce memory requirements
|
||||
for decompression.
|
||||
|
||||
|
||||
2) LZMA e file.bin file.lzma -lc0 -lp2
|
||||
|
||||
compresses file.bin to file.lzma with settings suitable
|
||||
for 32-bit periodical data (for example, ARM or MIPS code).
|
||||
|
||||
3) LZMA d file.lzma file.bin
|
||||
|
||||
decompresses file.lzma to file.bin.
|
||||
|
||||
|
||||
Compression ratio hints
|
||||
-----------------------
|
||||
|
||||
Recommendations
|
||||
---------------
|
||||
|
||||
To increase compression ratio for LZMA compressing it's desirable
|
||||
to have aligned data (if it's possible) and also it's desirable to locate
|
||||
data in such order, where code is grouped in one place and data is
|
||||
grouped in other place (it's better than such mixing: code, data, code,
|
||||
data, ...).
|
||||
|
||||
|
||||
Using Filters
|
||||
-------------
|
||||
You can increase compression ratio for some data types, using
|
||||
special filters before compressing. For example, it's possible to
|
||||
increase compression ratio on 5-10% for code for those CPU ISAs:
|
||||
x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.
|
||||
|
||||
You can find C/C++ source code of such filters in folder "7zip/Compress/Branch"
|
||||
|
||||
You can check compression ratio gain of these filters with such
|
||||
7-Zip commands (example for ARM code):
|
||||
No filter:
|
||||
7z a a1.7z a.bin -m0=lzma
|
||||
|
||||
With filter for little-endian ARM code:
|
||||
7z a a2.7z a.bin -m0=bc_arm -m1=lzma
|
||||
|
||||
With filter for big-endian ARM code (using additional Swap4 filter):
|
||||
7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma
|
||||
|
||||
It works in such manner:
|
||||
Compressing = Filter_encoding + LZMA_encoding
|
||||
Decompressing = LZMA_decoding + Filter_decoding
|
||||
|
||||
Compressing and decompressing speed of such filters is very high,
|
||||
so it will not increase decompressing time too much.
|
||||
Moreover, it reduces decompression time for LZMA_decoding,
|
||||
since compression ratio with filtering is higher.
|
||||
|
||||
These filters convert CALL (calling procedure) instructions
|
||||
from relative offsets to absolute addresses, so such data becomes more
|
||||
compressible. Source code of these CALL filters is pretty simple
|
||||
(about 20 lines of C++), so you can convert it from C++ version yourself.
|
||||
|
||||
For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
|
||||
|
||||
|
||||
LZMA compressed file format
|
||||
---------------------------
|
||||
Offset Size Description
|
||||
0 1 Special LZMA properties for compressed data
|
||||
1 4 Dictionary size (little endian)
|
||||
5 8 Uncompressed size (little endian). -1 means unknown size
|
||||
13 Compressed data
|
||||
|
||||
|
||||
ANSI-C LZMA Decoder
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To compile ANSI-C LZMA Decoder you can use one of the following files sets:
|
||||
1) LzmaDecode.h + LzmaDecode.c + LzmaTest.c (fastest version)
|
||||
2) LzmaDecode.h + LzmaDecodeSize.c + LzmaTest.c (old size-optimized version)
|
||||
3) LzmaStateDecode.h + LzmaStateDecode.c + LzmaStateTest.c (zlib-like interface)
|
||||
|
||||
|
||||
Memory requirements for LZMA decoding
|
||||
-------------------------------------
|
||||
|
||||
LZMA decoder doesn't allocate memory itself, so you must
|
||||
allocate memory and send it to LZMA.
|
||||
|
||||
Stack usage of LZMA decoding function for local variables is not
|
||||
larger than 200 bytes.
|
||||
|
||||
How To decompress data
|
||||
----------------------
|
||||
|
||||
LZMA Decoder (ANSI-C version) now supports 5 interfaces:
|
||||
1) Single-call Decompressing
|
||||
2) Single-call Decompressing with input stream callback
|
||||
3) Multi-call Decompressing with output buffer
|
||||
4) Multi-call Decompressing with input callback and output buffer
|
||||
5) Multi-call State Decompressing (zlib-like interface)
|
||||
|
||||
Variant-5 is similar to Variant-4, but Variant-5 doesn't use callback functions.
|
||||
|
||||
Decompressing steps
|
||||
-------------------
|
||||
|
||||
1) read LZMA properties (5 bytes):
|
||||
unsigned char properties[LZMA_PROPERTIES_SIZE];
|
||||
|
||||
2) read uncompressed size (8 bytes, little-endian)
|
||||
|
||||
3) Decode properties:
|
||||
|
||||
CLzmaDecoderState state; /* it's 24-140 bytes structure, if int is 32-bit */
|
||||
|
||||
if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
|
||||
return PrintError(rs, "Incorrect stream properties");
|
||||
|
||||
4) Allocate memory block for internal Structures:
|
||||
|
||||
state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
|
||||
if (state.Probs == 0)
|
||||
return PrintError(rs, kCantAllocateMessage);
|
||||
|
||||
LZMA decoder uses array of CProb variables as internal structure.
|
||||
By default, CProb is unsigned_short. But you can define _LZMA_PROB32 to make
|
||||
it unsigned_int. It can increase speed on some 32-bit CPUs, but memory
|
||||
usage will be doubled in that case.
|
||||
|
||||
|
||||
5) Main Decompressing
|
||||
|
||||
You must use one of the following interfaces:
|
||||
|
||||
5.1 Single-call Decompressing
|
||||
-----------------------------
|
||||
When to use: RAM->RAM decompressing
|
||||
Compile files: LzmaDecode.h, LzmaDecode.c
|
||||
Compile defines: no defines
|
||||
Memory Requirements:
|
||||
- Input buffer: compressed size
|
||||
- Output buffer: uncompressed size
|
||||
- LZMA Internal Structures (~16 KB for default settings)
|
||||
|
||||
Interface:
|
||||
int res = LzmaDecode(&state,
|
||||
inStream, compressedSize, &inProcessed,
|
||||
outStream, outSize, &outProcessed);
|
||||
|
||||
|
||||
5.2 Single-call Decompressing with input stream callback
|
||||
--------------------------------------------------------
|
||||
When to use: File->RAM or Flash->RAM decompressing.
|
||||
Compile files: LzmaDecode.h, LzmaDecode.c
|
||||
Compile defines: _LZMA_IN_CB
|
||||
Memory Requirements:
|
||||
- Buffer for input stream: any size (for example, 16 KB)
|
||||
- Output buffer: uncompressed size
|
||||
- LZMA Internal Structures (~16 KB for default settings)
|
||||
|
||||
Interface:
|
||||
typedef struct _CBuffer
|
||||
{
|
||||
ILzmaInCallback InCallback;
|
||||
FILE *File;
|
||||
unsigned char Buffer[kInBufferSize];
|
||||
} CBuffer;
|
||||
|
||||
int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
|
||||
{
|
||||
CBuffer *bo = (CBuffer *)object;
|
||||
*buffer = bo->Buffer;
|
||||
*size = MyReadFile(bo->File, bo->Buffer, kInBufferSize);
|
||||
return LZMA_RESULT_OK;
|
||||
}
|
||||
|
||||
CBuffer g_InBuffer;
|
||||
|
||||
g_InBuffer.File = inFile;
|
||||
g_InBuffer.InCallback.Read = LzmaReadCompressed;
|
||||
int res = LzmaDecode(&state,
|
||||
&g_InBuffer.InCallback,
|
||||
outStream, outSize, &outProcessed);
|
||||
|
||||
|
||||
5.3 Multi-call decompressing with output buffer
|
||||
-----------------------------------------------
|
||||
When to use: RAM->File decompressing
|
||||
Compile files: LzmaDecode.h, LzmaDecode.c
|
||||
Compile defines: _LZMA_OUT_READ
|
||||
Memory Requirements:
|
||||
- Input buffer: compressed size
|
||||
- Buffer for output stream: any size (for example, 16 KB)
|
||||
- LZMA Internal Structures (~16 KB for default settings)
|
||||
- LZMA dictionary (dictionary size is encoded in stream properties)
|
||||
|
||||
Interface:
|
||||
|
||||
state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
|
||||
|
||||
LzmaDecoderInit(&state);
|
||||
do
|
||||
{
|
||||
LzmaDecode(&state,
|
||||
inBuffer, inAvail, &inProcessed,
|
||||
g_OutBuffer, outAvail, &outProcessed);
|
||||
inAvail -= inProcessed;
|
||||
inBuffer += inProcessed;
|
||||
}
|
||||
while you need more bytes
|
||||
|
||||
see LzmaTest.c for more details.
|
||||
|
||||
|
||||
5.4 Multi-call decompressing with input callback and output buffer
|
||||
------------------------------------------------------------------
|
||||
When to use: File->File decompressing
|
||||
Compile files: LzmaDecode.h, LzmaDecode.c
|
||||
Compile defines: _LZMA_IN_CB, _LZMA_OUT_READ
|
||||
Memory Requirements:
|
||||
- Buffer for input stream: any size (for example, 16 KB)
|
||||
- Buffer for output stream: any size (for example, 16 KB)
|
||||
- LZMA Internal Structures (~16 KB for default settings)
|
||||
- LZMA dictionary (dictionary size is encoded in stream properties)
|
||||
|
||||
Interface:
|
||||
|
||||
state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
|
||||
|
||||
LzmaDecoderInit(&state);
|
||||
do
|
||||
{
|
||||
LzmaDecode(&state,
|
||||
&bo.InCallback,
|
||||
g_OutBuffer, outAvail, &outProcessed);
|
||||
}
|
||||
while you need more bytes
|
||||
|
||||
see LzmaTest.c for more details:
|
||||
|
||||
|
||||
5.5 Multi-call State Decompressing (zlib-like interface)
|
||||
------------------------------------------------------------------
|
||||
When to use: file->file decompressing
|
||||
Compile files: LzmaStateDecode.h, LzmaStateDecode.c
|
||||
Compile defines:
|
||||
Memory Requirements:
|
||||
- Buffer for input stream: any size (for example, 16 KB)
|
||||
- Buffer for output stream: any size (for example, 16 KB)
|
||||
- LZMA Internal Structures (~16 KB for default settings)
|
||||
- LZMA dictionary (dictionary size is encoded in stream properties)
|
||||
|
||||
Interface:
|
||||
|
||||
state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
|
||||
|
||||
|
||||
LzmaDecoderInit(&state);
|
||||
do
|
||||
{
|
||||
res = LzmaDecode(&state,
|
||||
inBuffer, inAvail, &inProcessed,
|
||||
g_OutBuffer, outAvail, &outProcessed,
|
||||
finishDecoding);
|
||||
inAvail -= inProcessed;
|
||||
inBuffer += inProcessed;
|
||||
}
|
||||
while you need more bytes
|
||||
|
||||
see LzmaStateTest.c for more details:
|
||||
|
||||
|
||||
6) Free all allocated blocks
|
||||
|
||||
|
||||
Note
|
||||
----
|
||||
LzmaDecodeSize.c is size-optimized version of LzmaDecode.c.
|
||||
But compiled code of LzmaDecodeSize.c can be larger than
|
||||
compiled code of LzmaDecode.c. So it's better to use
|
||||
LzmaDecode.c in most cases.
|
||||
|
||||
|
||||
EXIT codes
|
||||
-----------
|
||||
|
||||
LZMA decoder can return one of the following codes:
|
||||
|
||||
#define LZMA_RESULT_OK 0
|
||||
#define LZMA_RESULT_DATA_ERROR 1
|
||||
|
||||
If you use callback function for input data and you return some
|
||||
error code, LZMA Decoder also returns that code.
|
||||
|
||||
|
||||
|
||||
LZMA Defines
|
||||
------------
|
||||
|
||||
_LZMA_IN_CB - Use callback for input data
|
||||
|
||||
_LZMA_OUT_READ - Use read function for output data
|
||||
|
||||
_LZMA_LOC_OPT - Enable local speed optimizations inside code.
|
||||
_LZMA_LOC_OPT is only for LzmaDecodeSize.c (size-optimized version).
|
||||
_LZMA_LOC_OPT doesn't affect LzmaDecode.c (speed-optimized version)
|
||||
and LzmaStateDecode.c
|
||||
|
||||
_LZMA_PROB32 - It can increase speed on some 32-bit CPUs,
|
||||
but memory usage will be doubled in that case
|
||||
|
||||
_LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler
|
||||
and long is 32-bit.
|
||||
|
||||
_LZMA_SYSTEM_SIZE_T - Define it if you want to use system's size_t.
|
||||
You can use it to enable 64-bit sizes supporting
|
||||
|
||||
|
||||
|
||||
C++ LZMA Encoder/Decoder
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
C++ LZMA code use COM-like interfaces. So if you want to use it,
|
||||
you can study basics of COM/OLE.
|
||||
|
||||
By default, LZMA Encoder contains all Match Finders.
|
||||
But for compressing it's enough to have just one of them.
|
||||
So for reducing size of compressing code you can define:
|
||||
#define COMPRESS_MF_BT
|
||||
#define COMPRESS_MF_BT4
|
||||
and it will use only bt4 match finder.
|
||||
|
||||
|
||||
---
|
||||
|
||||
http://www.7-zip.org
|
||||
http://www.7-zip.org/support.html
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "File_Extractor", "File_Extractor.vcproj", "{7AEC599C-7C82-4F00-AA60-411E0A359CB0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|x64.Build.0 = Debug|x64
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Release|Win32.Build.0 = Release|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Release|x64.ActiveCfg = Release|x64
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,537 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="File_Extractor"
|
||||
ProjectGUID="{7AEC599C-7C82-4F00-AA60-411E0A359CB0}"
|
||||
RootNamespace="File_Extractor"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)_temp"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
BuildLogFile="$(IntDir)\$(ProjectName)_BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\zlib"
|
||||
PreprocessorDefinitions="FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)_temp"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
BuildLogFile="$(IntDir)\$(ProjectName)_BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\zlib"
|
||||
PreprocessorDefinitions="FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)_temp"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
BuildLogFile="$(IntDir)\$(ProjectName)_BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\zlib"
|
||||
PreprocessorDefinitions="FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)_temp"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
BuildLogFile="$(IntDir)\$(ProjectName)_BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\zlib"
|
||||
PreprocessorDefinitions="FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<Filter
|
||||
Name="fex"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\fex\abstract_file.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Data_Reader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\fex.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\File_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Gzip_Reader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Single_File_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\unzip.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip7_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zlib_Inflater.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<Filter
|
||||
Name="fex"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\fex\abstract_file.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_endian.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_source.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Data_Reader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\fex.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\File_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Gzip_Reader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Single_File_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\unzip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip7_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zlib_Inflater.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="7z_C"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\7zCrc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\7zCrc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Alloc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Alloc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Types.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Compress"
|
||||
>
|
||||
<Filter
|
||||
Name="Branch"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchTypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86_2.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86_2.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Lzma"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Lzma\LzmaDecode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Lzma\LzmaDecode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Lzma\LzmaTypes.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Archive"
|
||||
>
|
||||
<Filter
|
||||
Name="7z"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zAlloc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zAlloc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zBuffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zBuffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zDecode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zDecode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zExtract.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zExtract.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zHeader.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zHeader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zIn.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zIn.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zItem.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zItem.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zMethodID.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zMethodID.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,387 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="File_Extractor"
|
||||
ProjectGUID="{7AEC599C-7C82-4F00-AA60-411E0A359CB0}"
|
||||
RootNamespace="File_Extractor"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)_temp"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="0"
|
||||
BuildLogFile="$(IntDir)\$(ProjectName)_BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(ProjectDir)..\zlib""
|
||||
PreprocessorDefinitions="FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)_temp"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
BuildLogFile="$(IntDir)\$(ProjectName)_BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""$(ProjectDir)..\zlib""
|
||||
PreprocessorDefinitions="FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
ProgramDataBaseFileName="$(IntDir)\$(ProjectName).pdb"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="fex"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\fex\abstract_file.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\abstract_file.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_endian.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\blargg_source.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Data_Reader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Data_Reader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\fex.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\fex.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\File_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\File_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Gzip_Reader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Gzip_Reader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Single_File_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Single_File_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\unzip.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\unzip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip7_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip7_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip_Extractor.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zip_Extractor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zlib_Inflater.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fex\Zlib_Inflater.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="7z"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\7zC.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\7zCrc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\7zCrc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Alloc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Alloc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\changes.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\lzma.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Types.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Archive"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zAlloc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zAlloc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zBuffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zBuffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zDecode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zDecode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zExtract.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zExtract.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zHeader.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zHeader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zIn.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zIn.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zItem.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zItem.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zMethodID.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Archive\7z\7zMethodID.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Compress"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchTypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86_2.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Branch\BranchX86_2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Lzma\LzmaDecode.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Lzma\LzmaDecode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\7z_C\Compress\Lzma\LzmaTypes.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
65
dependencies/File_Extractor-0.4.3/File_Extractor2008.vcproj.GOLIATH.Shawn.user
vendored
Normal file
65
dependencies/File_Extractor-0.4.3/File_Extractor2008.vcproj.GOLIATH.Shawn.user
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command=""
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="GOLIATH"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command=""
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="GOLIATH"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VisualBoyAdvance", "VBA2010.vcxproj", "{6D4C5EC8-933F-4C05-A1BF-498E658576DF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "File_Extractor", "..\..\..\dependencies\File_Extractor-0.4.3\File_Extractor2010.vcxproj", "{7AEC599C-7C82-4F00-AA60-411E0A359CB0}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "File_Extractor", "File_Extractor2010.vcxproj", "{7AEC599C-7C82-4F00-AA60-411E0A359CB0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -10,10 +9,6 @@ Global
|
|||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6D4C5EC8-933F-4C05-A1BF-498E658576DF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6D4C5EC8-933F-4C05-A1BF-498E658576DF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6D4C5EC8-933F-4C05-A1BF-498E658576DF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6D4C5EC8-933F-4C05-A1BF-498E658576DF}.Release|Win32.Build.0 = Release|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Release|Win32.ActiveCfg = Release|Win32
|
Binary file not shown.
|
@ -0,0 +1,147 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>File_Extractor</ProjectName>
|
||||
<ProjectGuid>{7AEC599C-7C82-4F00-AA60-411E0A359CB0}</ProjectGuid>
|
||||
<RootNamespace>File_Extractor</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<BuildLogFile>$(IntDir)$(ProjectName)_BuildLog.htm</BuildLogFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<BuildLogFile>$(IntDir)$(ProjectName)_BuildLog.htm</BuildLogFile>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.21006.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Platform)\$(Configuration)_temp\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Platform)\$(Configuration)_temp\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ExecutablePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);d:\Projects\Dev-Cpp\bin\;</ExecutablePath>
|
||||
<ExecutablePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);d:\Projects\Dev-Cpp\bin\;</ExecutablePath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;d:\Projects\dependencies\zlib\;c:\Program Files (x86)\Microsoft DirectX SDK (August 2009)\Include\;d:\Projects\dependencies\libpng\;c:\Program Files (x86)\OpenAL 1.1 SDK\include\;</IncludePath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;d:\Projects\dependencies\zlib\;c:\Program Files (x86)\Microsoft DirectX SDK (August 2009)\Include\;d:\Projects\dependencies\libpng\;c:\Program Files (x86)\OpenAL 1.1 SDK\include\;</IncludePath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;c:\Program Files (x86)\Microsoft DirectX SDK (August 2009)\Lib\x86\;c:\Program Files (x86)\OpenAL 1.1 SDK\libs\;d:\Projects\dependencies\libs\;</LibraryPath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;c:\Program Files (x86)\Microsoft DirectX SDK (August 2009)\Lib\x86\;c:\Program Files (x86)\OpenAL 1.1 SDK\libs\;d:\Projects\dependencies\libs\;</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>FEX_ENABLE_RAR;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="fex\abstract_file.cpp" />
|
||||
<ClCompile Include="fex\Data_Reader.cpp" />
|
||||
<ClCompile Include="fex\fex.cpp" />
|
||||
<ClCompile Include="fex\File_Extractor.cpp" />
|
||||
<ClCompile Include="fex\Gzip_Reader.cpp" />
|
||||
<ClCompile Include="fex\Single_File_Extractor.cpp" />
|
||||
<ClCompile Include="fex\unzip.cpp" />
|
||||
<ClCompile Include="fex\Zip7_Extractor.cpp" />
|
||||
<ClCompile Include="fex\Zip_Extractor.cpp" />
|
||||
<ClCompile Include="fex\Zlib_Inflater.cpp" />
|
||||
<ClCompile Include="7z_C\7zCrc.c" />
|
||||
<ClCompile Include="7z_C\Alloc.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zAlloc.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zBuffer.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zDecode.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zExtract.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zHeader.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zIn.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zItem.c" />
|
||||
<ClCompile Include="7z_C\Archive\7z\7zMethodID.c" />
|
||||
<ClCompile Include="7z_C\Compress\Branch\BranchX86.c" />
|
||||
<ClCompile Include="7z_C\Compress\Branch\BranchX86_2.c" />
|
||||
<ClCompile Include="7z_C\Compress\Lzma\LzmaDecode.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="fex\abstract_file.h" />
|
||||
<ClInclude Include="fex\blargg_common.h" />
|
||||
<ClInclude Include="fex\blargg_config.h" />
|
||||
<ClInclude Include="fex\blargg_endian.h" />
|
||||
<ClInclude Include="fex\blargg_source.h" />
|
||||
<ClInclude Include="fex\Data_Reader.h" />
|
||||
<ClInclude Include="fex\fex.h" />
|
||||
<ClInclude Include="fex\File_Extractor.h" />
|
||||
<ClInclude Include="fex\Gzip_Reader.h" />
|
||||
<ClInclude Include="fex\Single_File_Extractor.h" />
|
||||
<ClInclude Include="fex\unzip.h" />
|
||||
<ClInclude Include="fex\Zip7_Extractor.h" />
|
||||
<ClInclude Include="fex\Zip_Extractor.h" />
|
||||
<ClInclude Include="fex\Zlib_Inflater.h" />
|
||||
<ClInclude Include="7z_C\7zCrc.h" />
|
||||
<ClInclude Include="7z_C\Alloc.h" />
|
||||
<ClInclude Include="7z_C\Types.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zAlloc.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zBuffer.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zDecode.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zExtract.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zHeader.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zIn.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zItem.h" />
|
||||
<ClInclude Include="7z_C\Archive\7z\7zMethodID.h" />
|
||||
<ClInclude Include="7z_C\Compress\Branch\BranchTypes.h" />
|
||||
<ClInclude Include="7z_C\Compress\Branch\BranchX86.h" />
|
||||
<ClInclude Include="7z_C\Compress\Branch\BranchX86_2.h" />
|
||||
<ClInclude Include="7z_C\Compress\Lzma\LzmaDecode.h" />
|
||||
<ClInclude Include="7z_C\Compress\Lzma\LzmaTypes.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="7z_C\7zC.txt" />
|
||||
<None Include="7z_C\changes.txt" />
|
||||
<None Include="7z_C\lzma.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,191 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="7z">
|
||||
<UniqueIdentifier>{389faf79-0326-47e9-957c-9a482f94e2e2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="7z\Archive">
|
||||
<UniqueIdentifier>{9e671547-6550-414c-8170-a013093aafe7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="7z\Compress">
|
||||
<UniqueIdentifier>{9a0c91a6-c1ce-4a79-94d6-2459b4171bff}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="fex">
|
||||
<UniqueIdentifier>{e99e7ce7-b7cb-42d2-8e89-e2005d013c0e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="7z_C\7zCrc.c">
|
||||
<Filter>7z</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Alloc.c">
|
||||
<Filter>7z</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zAlloc.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zBuffer.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zDecode.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zExtract.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zHeader.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zIn.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zItem.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Archive\7z\7zMethodID.c">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Compress\Branch\BranchX86.c">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Compress\Branch\BranchX86_2.c">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="7z_C\Compress\Lzma\LzmaDecode.c">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\abstract_file.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\Data_Reader.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\fex.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\File_Extractor.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\Gzip_Reader.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\Single_File_Extractor.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\unzip.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\Zip7_Extractor.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\Zip_Extractor.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fex\Zlib_Inflater.cpp">
|
||||
<Filter>fex</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="7z_C\7zCrc.h">
|
||||
<Filter>7z</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Alloc.h">
|
||||
<Filter>7z</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zAlloc.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zBuffer.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zDecode.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zExtract.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zHeader.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zIn.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zItem.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Archive\7z\7zMethodID.h">
|
||||
<Filter>7z\Archive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Compress\Branch\BranchTypes.h">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Compress\Branch\BranchX86.h">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Compress\Branch\BranchX86_2.h">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Compress\Lzma\LzmaDecode.h">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Compress\Lzma\LzmaTypes.h">
|
||||
<Filter>7z\Compress</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="7z_C\Types.h">
|
||||
<Filter>7z</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\abstract_file.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\blargg_common.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\blargg_config.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\blargg_endian.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\blargg_source.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\Data_Reader.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\fex.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\File_Extractor.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\Gzip_Reader.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\Single_File_Extractor.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\unzip.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\Zip7_Extractor.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\Zip_Extractor.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="fex\Zlib_Inflater.h">
|
||||
<Filter>fex</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="7z_C\7zC.txt">
|
||||
<Filter>7z</Filter>
|
||||
</None>
|
||||
<None Include="7z_C\changes.txt">
|
||||
<Filter>7z</Filter>
|
||||
</None>
|
||||
<None Include="7z_C\lzma.txt">
|
||||
<Filter>7z</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
dependencies/File_Extractor-0.4.3/Win32/Debug_temp/File_Extractor_BuildLog.htm
vendored
Normal file
BIN
dependencies/File_Extractor-0.4.3/Win32/Debug_temp/File_Extractor_BuildLog.htm
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
dependencies/File_Extractor-0.4.3/Win32/Debug_temp/Single_File_Extractor.obj
vendored
Normal file
BIN
dependencies/File_Extractor-0.4.3/Win32/Debug_temp/Single_File_Extractor.obj
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
dependencies/File_Extractor-0.4.3/Win32/Release_temp/File_Extractor_BuildLog.htm
vendored
Normal file
BIN
dependencies/File_Extractor-0.4.3/Win32/Release_temp/File_Extractor_BuildLog.htm
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
dependencies/File_Extractor-0.4.3/Win32/Release_temp/Single_File_Extractor.obj
vendored
Normal file
BIN
dependencies/File_Extractor-0.4.3/Win32/Release_temp/Single_File_Extractor.obj
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,53 @@
|
|||
/* C example that opens an archive, lists its contents, and
|
||||
extracts the first several characters of each file. */
|
||||
|
||||
#include "fex/fex.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* If error is not NULL, prints it and exits program */
|
||||
static void error( const char* error );
|
||||
|
||||
int main( int argc, char* argv [] )
|
||||
{
|
||||
/* Path to archive */
|
||||
const char* path = (argc > 1 ? argv [argc - 1] : "test.zip");
|
||||
|
||||
/* Open archive */
|
||||
fex_err_t err;
|
||||
File_Extractor* fex = fex_open( path, &err );
|
||||
error( err );
|
||||
|
||||
/* Iterate over each file in archive */
|
||||
while ( !fex_done( fex ) )
|
||||
{
|
||||
char buf [50] = "";
|
||||
|
||||
/* Print size and name */
|
||||
const char* name = fex_name( fex );
|
||||
long size = fex_size( fex );
|
||||
printf( "## %3ld K %s\n", size / 1024, name );
|
||||
|
||||
/* Print first several characters of data */
|
||||
error( fex_read( fex, buf, (size < 49 ? size : 49) ) );
|
||||
printf( "%s\n", buf );
|
||||
|
||||
/* Go to next file in archive */
|
||||
error( fex_next( fex ) );
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
fex_close( fex );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void error( const char* error )
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, "Error: %s\n", error );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
File_Extractor 0.4.3
|
||||
--------------------
|
||||
Author : Shay Green <gblargg@gmail.com>
|
||||
Website : http://www.slack.net/~ant/
|
||||
License : GNU Lesser General Public License (LGPL) for all except unrar
|
||||
Language: C or C++
|
||||
|
||||
|
||||
Contents
|
||||
--------
|
||||
* Overview
|
||||
* Limitations
|
||||
* C and C++ interfaces
|
||||
* Extracting file data
|
||||
* Alternate interfaces: unzip.h and unrarlib.h
|
||||
* Minimal version: fex_mini.cpp
|
||||
* Library compilation
|
||||
* Error handling
|
||||
* Solving problems
|
||||
* Thanks
|
||||
|
||||
|
||||
Overview
|
||||
--------
|
||||
This library contains several modules that support different archive
|
||||
formats. They have a common interface allowing an archive to be opened,
|
||||
scanned, and extracted from. To use an archive, do the following:
|
||||
|
||||
* Open file using appropriate extractor.
|
||||
* See if at end of archive.
|
||||
* Get info for current file and/or extract data from it.
|
||||
* Go to next file and check if at end of archive and repeat above.
|
||||
* If desired at any point, rewind and scan the archive again.
|
||||
* When done, close archive.
|
||||
|
||||
If support for one or more archive types is not needed, many of the
|
||||
library sources can be eliminated. Refer to the files list in readme.txt
|
||||
to find what can be removed.
|
||||
|
||||
|
||||
Details
|
||||
-------
|
||||
All archives:
|
||||
* A file's checksum is verified only if all the file's data is read from
|
||||
the archive.
|
||||
* Encryption, segmentation, 2GB and larger files, and other extra
|
||||
features are not supported.
|
||||
|
||||
GZ archives:
|
||||
* Only gzip archives of a single file are supported. If it has multiple
|
||||
files, the reported size will be wrong. Multi-file gzip files are rare.
|
||||
|
||||
ZIP archives:
|
||||
* Supports files compressed using deflation or no compression. Other
|
||||
compression schemes are not supported.
|
||||
* Archive must have a valid directory structure at the end.
|
||||
* Optimized file access reduces reads and keeps them aligned
|
||||
|
||||
RAR archives:
|
||||
* Support for really old 1.x archives might not work. Send me some test
|
||||
archives as I couldn't find any.
|
||||
|
||||
7-zip:
|
||||
* Solid archives currently can use lots of memory.
|
||||
* Modification date isn't supported.
|
||||
|
||||
|
||||
C and C++ interfaces
|
||||
--------------------
|
||||
This library includes a C interface in fex.h, which can be used from C
|
||||
and C++. If this is being compiled as a shared library (rather than
|
||||
linking statically), only the C interface in fex.h should be used since
|
||||
it will change less in future versions.
|
||||
|
||||
The native C++ interface is in File_Extractor.h and supports more ways
|
||||
of reading data and accessing files. Both interfaces can be used
|
||||
together in C++ code without problems. The interfaces correspond in a
|
||||
consistent way:
|
||||
|
||||
C interface C++ interface
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
File_Extractor* fex; File_Extractor* fex;
|
||||
|
||||
fex_open( path, &fex ); fex_open( path, &fex );
|
||||
|
||||
fex_done( fex ); fex->done();
|
||||
|
||||
fex_read( fex, out, count ); fex->read( out, count );
|
||||
|
||||
fex_close( fex ); delete fex;
|
||||
|
||||
The archive extractor classes are derived from File_Extractor, which
|
||||
allows a File_Extractor* to point to any type of extractor. There is no
|
||||
need to use concrete types directly (Zip_Extractor, etc.).
|
||||
|
||||
|
||||
Extracting file data
|
||||
--------------------
|
||||
Data for a file in an archive can be accessed in three ways:
|
||||
|
||||
* Make one or more calls to read().
|
||||
* Get a pointer to the file's data in memory.
|
||||
* Have extractor write data to Data_Writer you provide (C++ only).
|
||||
|
||||
Each archive type has an optimal access method that you might use if you
|
||||
were using only one archive type and wanted to avoid extra memory
|
||||
allocation or copying. Single_File_Extractor and Zip_Extractor favor
|
||||
read(), Zip7_Extractor favors getting a pointer to data in memory, and
|
||||
Rar_Extractor favors writing the data to a Data_Writer.
|
||||
|
||||
You should generally use whatever method is most convenient in your
|
||||
program. In most cases you will be keeping a copy of the data in memory
|
||||
after closing the archive, so you'll want to use read(). As long as you
|
||||
read the ENTIRE file's contents in one call to read(), your code will be
|
||||
most efficient and won't involve any extra memory allocation. If you
|
||||
only need the first portion of the file and will not be reading the rest
|
||||
(for example, if scanning headers only), you can use the optimized
|
||||
read_once() function instead of the normal read().
|
||||
|
||||
|
||||
Alternate interfaces: unzip.h and unrarlib.h
|
||||
--------------------------------------------
|
||||
If your code already uses the unzip.h or unrarlib.h library, you can
|
||||
begin using fex with minimal/no changes to your code by using the
|
||||
included wrappers. Most unrarlib.h functions are supported, and the main
|
||||
unzip.h functions are supported. Only basic file information is returned
|
||||
by each; things like dates and directories are not supported. These
|
||||
header files should NOT be used if you're writing new code, since they
|
||||
are inferior to the fex.h interface.
|
||||
|
||||
Both of these header files define FEX_WRAPPER to 1, so your code can
|
||||
check for that macro and if defined, support additional archive formats
|
||||
rather than just .rar or .zip.
|
||||
|
||||
|
||||
Minimal version: fex_mini.cpp
|
||||
-----------------------------
|
||||
You can use fex_mini.cpp and fex.h as an absolute minimum version. If
|
||||
you have zlib installed and HAVE_ZLIB_H defined, gzipped files are
|
||||
supported, otherwise only uncompressed files are supported. No other
|
||||
source files are required for this version. No changes to your source
|
||||
are necessary as long as you use only fex.h functionality.
|
||||
|
||||
|
||||
Library compilation
|
||||
-------------------
|
||||
While this library is written in C++, it should easily link in a C
|
||||
program WITHOUT needing the standard C++ library. It doesn't use
|
||||
exception handling or run-time type information (RTTI), so you can
|
||||
disable these in your C++ compiler to increase efficiency.
|
||||
|
||||
If you're building a shared library (DLL), I HIGHLY recommend only
|
||||
exporting the C interface from fex.h, as the C++ interface exposes
|
||||
implementation details that will surely break link compatibility across
|
||||
versions. If you aren't familiar with symbol exporting, just be sure you
|
||||
only use fex.h to access the shared library.
|
||||
|
||||
If you're using C and compiling with GCC, I recommend the following
|
||||
command-line options when compiling the library source, otherwise GCC
|
||||
will insert calls to the standard C++ library and require that it be
|
||||
linked in:
|
||||
|
||||
-fno-rtti -fno-exceptions
|
||||
|
||||
|
||||
Error handling
|
||||
--------------
|
||||
Functions that can fail have a return type of fex_err_t (blargg_err_t in
|
||||
the C++ interfaces), which is a pointer to an error string, const char*.
|
||||
If a function is successful it returns NULL. Logic errors that can be
|
||||
easily avoided are checked with debug-only assertions; error return
|
||||
values are only used for genuine run-time errors that can't be easily
|
||||
prevented in advance (out of memory, I/O errors, incompatible file
|
||||
data). All return values should be checked after calling library
|
||||
functions.
|
||||
|
||||
To improve usability for C programmers, C++ programmers unfamiliar with
|
||||
exceptions, and compatibility with older C++ compilers, the library does
|
||||
NOT throw any C++ exceptions, and uses malloc() instead of the standard
|
||||
operator new. This means that in C++ you MUST check for NULL when
|
||||
creating a library object with the new operator.
|
||||
|
||||
|
||||
Solving problems
|
||||
----------------
|
||||
If you're having problems, try the following:
|
||||
|
||||
* Enable debugging support in your environment. This enables assertions
|
||||
and other run-time checks. In particular, be sure NDEBUG isn't defined.
|
||||
|
||||
* Turn the compiler's optimizer is off. Sometimes an optimizer generates
|
||||
bad code.
|
||||
|
||||
* If multiple threads are being used, ensure that only one at a time is
|
||||
accessing a given set of objects from the library. This library is not
|
||||
in general thread-safe, though independent objects can be used in
|
||||
separate threads.
|
||||
|
||||
* If all else fails, see if the demo works.
|
||||
|
||||
|
||||
Thanks
|
||||
------
|
||||
Thanks to Richard Bannister, Kode54, and DJRobX for testing and giving
|
||||
feedback for the library. Thanks to the authors of zlib, unrar, and
|
||||
7-zip.
|
||||
|
||||
--
|
||||
Shay Green <gblargg@gmail.com>
|
|
@ -0,0 +1,323 @@
|
|||
// File_Extractor 0.4.3. http://www.slack.net/~ant/
|
||||
|
||||
#include "Data_Reader.h"
|
||||
|
||||
#include "blargg_endian.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Copyright (C) 2005-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
const char Data_Reader::eof_error [] = "Unexpected end of file";
|
||||
|
||||
blargg_err_t Data_Reader::read( void* p, long s )
|
||||
{
|
||||
long result = read_avail( p, s );
|
||||
if ( result == s )
|
||||
return 0;
|
||||
|
||||
if ( result < 0 )
|
||||
return "Read error";
|
||||
|
||||
return eof_error;
|
||||
}
|
||||
|
||||
blargg_err_t Data_Reader::skip( long count )
|
||||
{
|
||||
char buf [512];
|
||||
while ( count )
|
||||
{
|
||||
long n = sizeof buf;
|
||||
if ( n > count )
|
||||
n = count;
|
||||
count -= n;
|
||||
RETURN_ERR( read( buf, n ) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long File_Reader::remain() const { return size() - tell(); }
|
||||
|
||||
blargg_err_t File_Reader::skip( long n )
|
||||
{
|
||||
assert( n >= 0 );
|
||||
if ( !n )
|
||||
return 0;
|
||||
return seek( tell() + n );
|
||||
}
|
||||
|
||||
// Subset_Reader
|
||||
|
||||
Subset_Reader::Subset_Reader( Data_Reader* dr, long size )
|
||||
{
|
||||
in = dr;
|
||||
remain_ = dr->remain();
|
||||
if ( remain_ > size )
|
||||
remain_ = size;
|
||||
}
|
||||
|
||||
long Subset_Reader::remain() const { return remain_; }
|
||||
|
||||
long Subset_Reader::read_avail( void* p, long s )
|
||||
{
|
||||
if ( s > remain_ )
|
||||
s = remain_;
|
||||
remain_ -= s;
|
||||
return in->read_avail( p, s );
|
||||
}
|
||||
|
||||
// Remaining_Reader
|
||||
|
||||
Remaining_Reader::Remaining_Reader( void const* h, long size, Data_Reader* r )
|
||||
{
|
||||
header = (char const*) h;
|
||||
header_end = header + size;
|
||||
in = r;
|
||||
}
|
||||
|
||||
long Remaining_Reader::remain() const { return header_end - header + in->remain(); }
|
||||
|
||||
long Remaining_Reader::read_first( void* out, long count )
|
||||
{
|
||||
long first = header_end - header;
|
||||
if ( first )
|
||||
{
|
||||
if ( first > count )
|
||||
first = count;
|
||||
void const* old = header;
|
||||
header += first;
|
||||
memcpy( out, old, first );
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
long Remaining_Reader::read_avail( void* out, long count )
|
||||
{
|
||||
long first = read_first( out, count );
|
||||
long second = count - first;
|
||||
if ( second )
|
||||
{
|
||||
second = in->read_avail( (char*) out + first, second );
|
||||
if ( second <= 0 )
|
||||
return second;
|
||||
}
|
||||
return first + second;
|
||||
}
|
||||
|
||||
blargg_err_t Remaining_Reader::read( void* out, long count )
|
||||
{
|
||||
long first = read_first( out, count );
|
||||
long second = count - first;
|
||||
if ( !second )
|
||||
return 0;
|
||||
return in->read( (char*) out + first, second );
|
||||
}
|
||||
|
||||
// Mem_File_Reader
|
||||
|
||||
Mem_File_Reader::Mem_File_Reader( const void* p, long s ) :
|
||||
begin( (const char*) p ),
|
||||
size_( s )
|
||||
{
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
long Mem_File_Reader::size() const { return size_; }
|
||||
|
||||
long Mem_File_Reader::read_avail( void* p, long s )
|
||||
{
|
||||
long r = remain();
|
||||
if ( s > r )
|
||||
s = r;
|
||||
memcpy( p, begin + pos, s );
|
||||
pos += s;
|
||||
return s;
|
||||
}
|
||||
|
||||
long Mem_File_Reader::tell() const { return pos; }
|
||||
|
||||
blargg_err_t Mem_File_Reader::seek( long n )
|
||||
{
|
||||
if ( n > size_ )
|
||||
return eof_error;
|
||||
pos = n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Callback_Reader
|
||||
|
||||
Callback_Reader::Callback_Reader( callback_t c, long size, void* d ) :
|
||||
callback( c ),
|
||||
data( d )
|
||||
{
|
||||
remain_ = size;
|
||||
}
|
||||
|
||||
long Callback_Reader::remain() const { return remain_; }
|
||||
|
||||
long Callback_Reader::read_avail( void* out, long count )
|
||||
{
|
||||
if ( count > remain_ )
|
||||
count = remain_;
|
||||
|
||||
if ( Callback_Reader::read( out, count ) )
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
blargg_err_t Callback_Reader::read( void* out, long count )
|
||||
{
|
||||
if ( count > remain_ )
|
||||
return eof_error;
|
||||
return callback( data, out, count );
|
||||
}
|
||||
|
||||
// Std_File_Reader
|
||||
|
||||
Std_File_Reader::Std_File_Reader() : file_( 0 ) { }
|
||||
|
||||
Std_File_Reader::~Std_File_Reader() { close(); }
|
||||
|
||||
blargg_err_t Std_File_Reader::open( const char* path )
|
||||
{
|
||||
file_ = fopen( path, "rb" );
|
||||
if ( !file_ )
|
||||
return "Couldn't open file";
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Std_File_Reader::make_unbuffered()
|
||||
{
|
||||
if ( setvbuf( (FILE*) file_, 0, _IONBF, 0 ) )
|
||||
check( false ); // shouldn't fail, but OK if it does
|
||||
}
|
||||
|
||||
long Std_File_Reader::size() const
|
||||
{
|
||||
long pos = tell();
|
||||
fseek( (FILE*) file_, 0, SEEK_END );
|
||||
long result = tell();
|
||||
fseek( (FILE*) file_, pos, SEEK_SET );
|
||||
return result;
|
||||
}
|
||||
|
||||
long Std_File_Reader::read_avail( void* p, long s )
|
||||
{
|
||||
return fread( p, 1, s, (FILE*) file_ );
|
||||
}
|
||||
|
||||
blargg_err_t Std_File_Reader::read( void* p, long s )
|
||||
{
|
||||
if ( s == (long) fread( p, 1, s, (FILE*) file_ ) )
|
||||
return 0;
|
||||
if ( feof( (FILE*) file_ ) )
|
||||
return eof_error;
|
||||
return "Couldn't read from file";
|
||||
}
|
||||
|
||||
long Std_File_Reader::tell() const { return ftell( (FILE*) file_ ); }
|
||||
|
||||
blargg_err_t Std_File_Reader::seek( long n )
|
||||
{
|
||||
if ( !fseek( (FILE*) file_, n, SEEK_SET ) )
|
||||
return 0;
|
||||
if ( n > size() )
|
||||
return eof_error;
|
||||
return "Error seeking in file";
|
||||
}
|
||||
|
||||
void Std_File_Reader::close()
|
||||
{
|
||||
if ( file_ )
|
||||
{
|
||||
fclose( (FILE*) file_ );
|
||||
file_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Gzip_File_Reader
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
static const char* get_gzip_eof( const char* path, long* eof )
|
||||
{
|
||||
FILE* file = fopen( path, "rb" );
|
||||
if ( !file )
|
||||
return "Couldn't open file";
|
||||
|
||||
unsigned char buf [4];
|
||||
if ( fread( buf, 2, 1, file ) > 0 && buf [0] == 0x1F && buf [1] == 0x8B )
|
||||
{
|
||||
fseek( file, -4, SEEK_END );
|
||||
fread( buf, 4, 1, file );
|
||||
*eof = get_le32( buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek( file, 0, SEEK_END );
|
||||
*eof = ftell( file );
|
||||
}
|
||||
const char* err = (ferror( file ) || feof( file )) ? "Couldn't get file size" : 0;
|
||||
fclose( file );
|
||||
return err;
|
||||
}
|
||||
|
||||
Gzip_File_Reader::Gzip_File_Reader() : file_( 0 ) { }
|
||||
|
||||
Gzip_File_Reader::~Gzip_File_Reader() { close(); }
|
||||
|
||||
blargg_err_t Gzip_File_Reader::open( const char* path )
|
||||
{
|
||||
close();
|
||||
|
||||
RETURN_ERR( get_gzip_eof( path, &size_ ) );
|
||||
|
||||
file_ = gzopen( path, "rb" );
|
||||
if ( !file_ )
|
||||
return "Couldn't open file";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
long Gzip_File_Reader::size() const { return size_; }
|
||||
|
||||
long Gzip_File_Reader::read_avail( void* p, long s ) { return gzread( file_, p, s ); }
|
||||
|
||||
long Gzip_File_Reader::tell() const { return gztell( file_ ); }
|
||||
|
||||
blargg_err_t Gzip_File_Reader::seek( long n )
|
||||
{
|
||||
if ( gzseek( file_, n, SEEK_SET ) >= 0 )
|
||||
return 0;
|
||||
|
||||
if ( n > size_ )
|
||||
return eof_error;
|
||||
|
||||
return "Error seeking in file";
|
||||
}
|
||||
|
||||
void Gzip_File_Reader::close()
|
||||
{
|
||||
if ( file_ )
|
||||
{
|
||||
gzclose( file_ );
|
||||
file_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,161 @@
|
|||
// Lightweight interface for reading data
|
||||
|
||||
// File_Extractor 0.4.3
|
||||
#ifndef DATA_READER_H
|
||||
#define DATA_READER_H
|
||||
|
||||
#include "blargg_common.h"
|
||||
|
||||
// Supports reading and finding out how many bytes are remaining
|
||||
class Data_Reader {
|
||||
public:
|
||||
virtual ~Data_Reader() { }
|
||||
|
||||
static const char eof_error []; // returned by read() when request goes beyond end
|
||||
|
||||
// Reads at most n bytes and returns number actually read, or negative if error.
|
||||
// Trying to read past end of file is NOT considered an error.
|
||||
virtual long read_avail( void*, long n ) BLARGG_PURE( { (void) n; return 0; } )
|
||||
|
||||
// Read exactly n bytes and returns error if they couldn't ALL be read.
|
||||
// Reading past end of file results in eof_error.
|
||||
virtual blargg_err_t read( void*, long n );
|
||||
|
||||
// Number of bytes remaining until end of file
|
||||
virtual long remain() const BLARGG_PURE( { return 0; } )
|
||||
|
||||
// Reads and discards n bytes. Skipping past end of file results in eof_error.
|
||||
virtual blargg_err_t skip( long n );
|
||||
|
||||
public:
|
||||
Data_Reader() { }
|
||||
typedef blargg_err_t error_t; // deprecated
|
||||
BLARGG_DISABLE_NOTHROW
|
||||
private:
|
||||
// noncopyable
|
||||
Data_Reader( const Data_Reader& );
|
||||
Data_Reader& operator = ( const Data_Reader& );
|
||||
};
|
||||
|
||||
// Supports seeking in addition to Data_Reader operations
|
||||
class File_Reader : public Data_Reader {
|
||||
public:
|
||||
// Size of file
|
||||
virtual long size() const BLARGG_PURE( { return 0; } )
|
||||
|
||||
// Current position in file
|
||||
virtual long tell() const BLARGG_PURE( { return 0; } )
|
||||
|
||||
// Goes to new position
|
||||
virtual blargg_err_t seek( long ) BLARGG_PURE( { return 0; } )
|
||||
|
||||
long remain() const;
|
||||
blargg_err_t skip( long n );
|
||||
};
|
||||
|
||||
// Disk file reader
|
||||
class Std_File_Reader : public File_Reader {
|
||||
public:
|
||||
blargg_err_t open( const char* path );
|
||||
void close();
|
||||
|
||||
// Switches to unbuffered mode. Useful if you are doing your
|
||||
// own buffering already.
|
||||
void make_unbuffered();
|
||||
|
||||
public:
|
||||
Std_File_Reader();
|
||||
~Std_File_Reader();
|
||||
long size() const;
|
||||
blargg_err_t read( void*, long );
|
||||
long read_avail( void*, long );
|
||||
long tell() const;
|
||||
blargg_err_t seek( long );
|
||||
private:
|
||||
void* file_;
|
||||
};
|
||||
|
||||
// Treats range of memory as a file
|
||||
class Mem_File_Reader : public File_Reader {
|
||||
public:
|
||||
Mem_File_Reader( const void* begin, long size );
|
||||
|
||||
public:
|
||||
long size() const;
|
||||
long read_avail( void*, long );
|
||||
long tell() const;
|
||||
blargg_err_t seek( long );
|
||||
private:
|
||||
const char* const begin;
|
||||
const long size_;
|
||||
long pos;
|
||||
};
|
||||
|
||||
// Makes it look like there are only count bytes remaining
|
||||
class Subset_Reader : public Data_Reader {
|
||||
public:
|
||||
Subset_Reader( Data_Reader*, long count );
|
||||
|
||||
public:
|
||||
long remain() const;
|
||||
long read_avail( void*, long );
|
||||
private:
|
||||
Data_Reader* in;
|
||||
long remain_;
|
||||
};
|
||||
|
||||
// Joins already-read header and remaining data into original file.
|
||||
// Meant for cases where you've already read header and don't want
|
||||
// to seek and re-read data (for efficiency).
|
||||
class Remaining_Reader : public Data_Reader {
|
||||
public:
|
||||
Remaining_Reader( void const* header, long header_size, Data_Reader* );
|
||||
|
||||
public:
|
||||
long remain() const;
|
||||
long read_avail( void*, long );
|
||||
blargg_err_t read( void*, long );
|
||||
private:
|
||||
char const* header;
|
||||
char const* header_end;
|
||||
Data_Reader* in;
|
||||
long read_first( void* out, long count );
|
||||
};
|
||||
|
||||
// Invokes callback function to read data. Size of data must be specified in advance.
|
||||
// Passes user_data unchanged to your callback.
|
||||
class Callback_Reader : public Data_Reader {
|
||||
public:
|
||||
typedef const char* (*callback_t)( void* user_data, void* out, long count );
|
||||
Callback_Reader( callback_t, long size, void* user_data = 0 );
|
||||
public:
|
||||
long read_avail( void*, long );
|
||||
blargg_err_t read( void*, long );
|
||||
long remain() const;
|
||||
private:
|
||||
callback_t const callback;
|
||||
void* const data;
|
||||
long remain_;
|
||||
};
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
// Gzip compressed file reader
|
||||
class Gzip_File_Reader : public File_Reader {
|
||||
public:
|
||||
blargg_err_t open( const char* path );
|
||||
void close();
|
||||
|
||||
public:
|
||||
Gzip_File_Reader();
|
||||
~Gzip_File_Reader();
|
||||
long size() const;
|
||||
long read_avail( void*, long );
|
||||
long tell() const;
|
||||
blargg_err_t seek( long );
|
||||
private:
|
||||
void* file_;
|
||||
long size_;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,247 @@
|
|||
// File_Extractor 0.4.3. http://www.slack.net/~ant/
|
||||
|
||||
#include "File_Extractor.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Copyright (C) 2005-2007 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
const char fex_wrong_file_type [] = "Archive format not supported";
|
||||
|
||||
File_Extractor::File_Extractor( fex_type_t t ) :
|
||||
type_( t )
|
||||
{
|
||||
user_data_ = 0;
|
||||
user_cleanup_ = 0;
|
||||
init_state();
|
||||
}
|
||||
|
||||
// Open
|
||||
|
||||
void File_Extractor::open_filter_( const char*, Std_File_Reader* ) { }
|
||||
|
||||
blargg_err_t File_Extractor::open( const char* path )
|
||||
{
|
||||
Std_File_Reader* in = BLARGG_NEW Std_File_Reader;
|
||||
CHECK_ALLOC( in );
|
||||
|
||||
blargg_err_t err = in->open( path );
|
||||
if ( !err )
|
||||
{
|
||||
open_filter_( path, in );
|
||||
err = this->open( in );
|
||||
}
|
||||
|
||||
if ( err )
|
||||
{
|
||||
delete in;
|
||||
return err;
|
||||
}
|
||||
|
||||
own_file();
|
||||
return 0;
|
||||
}
|
||||
|
||||
blargg_err_t File_Extractor::open( File_Reader* input )
|
||||
{
|
||||
require( input->tell() == 0 ); // needs to be at beginning
|
||||
close();
|
||||
reader_ = input;
|
||||
blargg_err_t err = open_();
|
||||
if ( !err )
|
||||
done_ = false;
|
||||
else
|
||||
close();
|
||||
return err;
|
||||
}
|
||||
|
||||
// Close
|
||||
|
||||
void File_Extractor::init_state()
|
||||
{
|
||||
done_ = true;
|
||||
scan_only_ = false;
|
||||
reader_ = 0;
|
||||
own_file_ = false;
|
||||
own_data_ = 0;
|
||||
clear_file();
|
||||
}
|
||||
|
||||
void File_Extractor::close()
|
||||
{
|
||||
close_();
|
||||
if ( own_file_ && reader_ )
|
||||
delete reader_;
|
||||
clear_file();
|
||||
init_state();
|
||||
}
|
||||
|
||||
File_Extractor::~File_Extractor()
|
||||
{
|
||||
// fails if derived class didn't call close() in its destructor
|
||||
check( !own_file_ && !reader_ );
|
||||
if ( user_cleanup_ )
|
||||
user_cleanup_( user_data_ );
|
||||
}
|
||||
|
||||
// Scanning
|
||||
|
||||
void File_Extractor::free_data()
|
||||
{
|
||||
data_ptr_ = 0;
|
||||
free( own_data_ );
|
||||
own_data_ = 0;
|
||||
}
|
||||
|
||||
void File_Extractor::clear_file()
|
||||
{
|
||||
set_info( 0, 0 );
|
||||
data_pos_ = 0;
|
||||
free_data();
|
||||
clear_file_();
|
||||
}
|
||||
|
||||
void File_Extractor::set_info( long size, const char* name, unsigned long date )
|
||||
{
|
||||
size_ = size;
|
||||
name_ = name;
|
||||
date_ = (date != 0xFFFFFFFF ? date : 0);
|
||||
}
|
||||
|
||||
blargg_err_t File_Extractor::next()
|
||||
{
|
||||
if ( done() )
|
||||
return "End of archive";
|
||||
|
||||
clear_file();
|
||||
blargg_err_t err = next_();
|
||||
if ( err )
|
||||
done_ = true;
|
||||
if ( done_ )
|
||||
clear_file();
|
||||
return err;
|
||||
}
|
||||
|
||||
blargg_err_t File_Extractor::rewind()
|
||||
{
|
||||
if ( !reader_ )
|
||||
return "No open archive";
|
||||
|
||||
done_ = false;
|
||||
scan_only_ = false;
|
||||
clear_file();
|
||||
|
||||
blargg_err_t err = rewind_();
|
||||
if ( err )
|
||||
{
|
||||
done_ = true;
|
||||
clear_file();
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
// Full extraction
|
||||
|
||||
blargg_err_t File_Extractor::data_( byte const*& out )
|
||||
{
|
||||
if ( !own_data_ )
|
||||
CHECK_ALLOC( own_data_ = (byte*) malloc( size_ ? size_ : 1 ) );
|
||||
|
||||
out = own_data_;
|
||||
return read_once( own_data_, size_ );
|
||||
}
|
||||
|
||||
unsigned char const* File_Extractor::data( blargg_err_t* error_out )
|
||||
{
|
||||
const char* error = 0;
|
||||
if ( !reader_ )
|
||||
{
|
||||
error = eof_error;
|
||||
}
|
||||
else if ( !data_ptr_ )
|
||||
{
|
||||
error = data_( data_ptr_ );
|
||||
if ( error )
|
||||
free_data();
|
||||
}
|
||||
|
||||
if ( error_out )
|
||||
*error_out = error;
|
||||
|
||||
return data_ptr_;
|
||||
}
|
||||
|
||||
blargg_err_t File_Extractor::extract( Data_Writer& out )
|
||||
{
|
||||
blargg_err_t error;
|
||||
byte const* p = data( &error );
|
||||
RETURN_ERR( error );
|
||||
|
||||
return out.write( p, size_ );
|
||||
}
|
||||
|
||||
blargg_err_t File_Extractor::read_once( void* out, long count )
|
||||
{
|
||||
Mem_Writer mem( out, count, 1 );
|
||||
return extract( mem );
|
||||
}
|
||||
|
||||
// Data_Reader functions
|
||||
|
||||
long File_Extractor::remain() const { return size_ - data_pos_; }
|
||||
|
||||
long File_Extractor::read_avail( void* out, long count )
|
||||
{
|
||||
if ( count )
|
||||
{
|
||||
long r = remain();
|
||||
if ( count > r )
|
||||
count = r;
|
||||
|
||||
if ( read( out, count ) )
|
||||
count = -1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
blargg_err_t File_Extractor::read( void* out, long count )
|
||||
{
|
||||
if ( count > remain() )
|
||||
return "End of file";
|
||||
|
||||
if ( count == size_ && !data_ptr_ )
|
||||
{
|
||||
// avoid temporary buffer when reading entire file in one call
|
||||
assert( data_pos_ == 0 );
|
||||
RETURN_ERR( read_once( out, count ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( count && !data_ptr_ )
|
||||
{
|
||||
blargg_err_t err;
|
||||
data( &err ); // sets data_ptr_
|
||||
RETURN_ERR( err );
|
||||
}
|
||||
|
||||
memcpy( out, data_ptr_ + data_pos_, count );
|
||||
}
|
||||
data_pos_ += count;
|
||||
if ( data_pos_ == size_ )
|
||||
free_data();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
// Compressed file archive interface (C++)
|
||||
|
||||
// File_Extractor 0.4.3
|
||||
#ifndef FILE_EXTRACTOR_H
|
||||
#define FILE_EXTRACTOR_H
|
||||
|
||||
#include "fex.h"
|
||||
#include "blargg_common.h"
|
||||
#include "abstract_file.h"
|
||||
|
||||
struct File_Extractor : private Data_Reader {
|
||||
public:
|
||||
// Open/close
|
||||
|
||||
// Opens archive
|
||||
blargg_err_t open( const char* path );
|
||||
|
||||
// Opens archive from custom data source. Keeps pointer to input
|
||||
// until close(), but does not delete reader at close() unless you
|
||||
// call own_file() before then.
|
||||
blargg_err_t open( File_Reader* input );
|
||||
|
||||
// Transfers ownership of current input file passed to open() so that
|
||||
// it will be deleted on close()
|
||||
void own_file() { own_file_ = true; }
|
||||
|
||||
// Closes archive and frees memory
|
||||
void close();
|
||||
|
||||
// Scanning
|
||||
|
||||
// True if end of archive has been reached
|
||||
bool done() const { return done_; }
|
||||
|
||||
// Path of current file in archive, using '/' as directory separator
|
||||
const char* name() const { return name_; }
|
||||
|
||||
// Size of current file, in bytes
|
||||
long size() const { return size_; }
|
||||
|
||||
// Modification date of file, in MS-DOS format (0 if unavailable).
|
||||
unsigned long dos_date() const { return date_; }
|
||||
|
||||
// Goes to next file (skips directories)
|
||||
blargg_err_t next();
|
||||
|
||||
// Goes back to first file in archive
|
||||
blargg_err_t rewind();
|
||||
|
||||
// Data extraction
|
||||
|
||||
// Read exactly n bytes and returns error if they couldn't ALL be read.
|
||||
// Reading past end of file results in eof_error.
|
||||
blargg_err_t read( void* out, long n );
|
||||
|
||||
// Reads at most n bytes and returns number actually read, or negative if error.
|
||||
// Trying to read past end of file is NOT considered an error.
|
||||
long read_avail( void* out, long n );
|
||||
|
||||
// Number of bytes remaining until end of current file
|
||||
long remain() const;
|
||||
|
||||
// Reads and discards n bytes. Skipping past end of file results in eof_error.
|
||||
blargg_err_t skip( long n ) { return Data_Reader::skip( n ); }
|
||||
|
||||
// Data_Reader to current file's data, so you can use standard Data_Reader
|
||||
// interface and not have to treat archives specially.
|
||||
Data_Reader& reader() { return *this; }
|
||||
|
||||
// Alternate ways of extracting file. Only one method may be used
|
||||
// once before calling next() or rewind().
|
||||
|
||||
// Extracts first n bytes and ignores rest. Faster than a normal read since it
|
||||
// doesn't have to be prepared to read/decompress more data.
|
||||
virtual blargg_err_t read_once( void* out, long n );
|
||||
|
||||
// Extracts all data and writes it to out
|
||||
virtual blargg_err_t extract( Data_Writer& out );
|
||||
|
||||
// Gets pointer to file's data. Returned pointer is valid until next call to
|
||||
// next(), rewind(), close(), or open(). Sets *error_out to error. OK to call
|
||||
// more than once in a row; returns same pointer in that case.
|
||||
typedef unsigned char byte;
|
||||
byte const* data( blargg_err_t* error_out );
|
||||
|
||||
// Other features
|
||||
|
||||
// Type of this extractor (fex_zip_type, etc.)
|
||||
fex_type_t type() const { return type_; }
|
||||
|
||||
// Hints that archive will either be only scanned (true), or might be extracted
|
||||
// from (false), improving performance on solid archives. Calling rewind()
|
||||
// resets this to the best default.
|
||||
void scan_only( bool b = true ) { scan_only_ = b; }
|
||||
|
||||
// Sets/gets pointer to data you want to associate with this object.
|
||||
// You can use this for whatever you want.
|
||||
void set_user_data( void* p ) { user_data_ = p; }
|
||||
void* user_data() const { return user_data_; }
|
||||
|
||||
// Registers cleanup function to be called when deleting this object. Passes
|
||||
// user_data to cleanup function. Pass NULL to clear any cleanup function.
|
||||
void set_user_cleanup( fex_user_cleanup_t func ) { user_cleanup_ = func; }
|
||||
|
||||
virtual ~File_Extractor();
|
||||
|
||||
public:
|
||||
BLARGG_DISABLE_NOTHROW
|
||||
File_Extractor( fex_type_t );
|
||||
Data_Reader::eof_error;
|
||||
protected:
|
||||
// Services for extractors
|
||||
File_Reader& file() const { return *reader_; }
|
||||
void set_done() { done_ = true; }
|
||||
void set_info( long size, const char* name, unsigned long date = 0 );
|
||||
bool is_scan_only() const { return scan_only_; }
|
||||
|
||||
// Overridden by extractors
|
||||
virtual void open_filter_( const char* path, Std_File_Reader* );
|
||||
virtual blargg_err_t open_() BLARGG_PURE( { return 0; } )
|
||||
virtual blargg_err_t next_() BLARGG_PURE( { return 0; } )
|
||||
virtual blargg_err_t rewind_() BLARGG_PURE( { return 0; } )
|
||||
virtual void close_() BLARGG_PURE( { } )
|
||||
virtual void clear_file_() { }
|
||||
virtual blargg_err_t data_( byte const*& out );
|
||||
private:
|
||||
fex_type_t const type_;
|
||||
File_Reader* reader_;
|
||||
bool own_file_;
|
||||
bool scan_only_;
|
||||
bool done_;
|
||||
|
||||
const char* name_;
|
||||
unsigned long date_;
|
||||
long size_;
|
||||
long data_pos_; // current position in data
|
||||
byte const* data_ptr_;
|
||||
byte* own_data_; // memory we allocated for data
|
||||
|
||||
void* user_data_;
|
||||
fex_user_cleanup_t user_cleanup_;
|
||||
|
||||
void init_state();
|
||||
void clear_file();
|
||||
void free_data();
|
||||
};
|
||||
|
||||
// Default to Std_File_Reader for archive access
|
||||
#ifndef FEX_FILE_READER
|
||||
#define FEX_FILE_READER Std_File_Reader
|
||||
#endif
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue