Minor bug fixes to new unrar code
parent
bfb319988f
commit
318b2cfed8
|
@ -33,7 +33,7 @@ unrar_err_t Archive::ReadHeader(size_t * ReadSize_)
|
||||||
if (Error!=unrar_ok)
|
if (Error!=unrar_ok)
|
||||||
return Error;
|
return Error;
|
||||||
|
|
||||||
if (ReadSize>0 & NextBlockPos<=CurBlockPos)
|
if (ReadSize>0 && NextBlockPos<=CurBlockPos)
|
||||||
return unrar_err_corrupt;
|
return unrar_err_corrupt;
|
||||||
|
|
||||||
*ReadSize_ = ReadSize;
|
*ReadSize_ = ReadSize;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// Based on public domain code written in 2012 by Samuel Neves
|
// Based on public domain code written in 2012 by Samuel Neves
|
||||||
|
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
extern const byte blake2s_sigma[10][16];
|
extern const byte blake2s_sigma[10][16];
|
||||||
|
|
||||||
// Initialization vector.
|
// Initialization vector.
|
||||||
|
@ -125,3 +127,5 @@ static int blake2s_compress_sse( blake2s_state *S, const byte block[BLAKE2S_BLOC
|
||||||
STORE( &S->h[4], _mm_xor_si128( ff1, _mm_xor_si128( row[1], row[3] ) ) );
|
STORE( &S->h[4], _mm_xor_si128( ff1, _mm_xor_si128( row[1], row[3] ) ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
#define PARALLELISM_DEGREE 8
|
#define PARALLELISM_DEGREE 8
|
||||||
|
|
||||||
void blake2sp_init( blake2sp_state *S )
|
void blake2sp_init( blake2sp_state *S )
|
||||||
|
@ -151,3 +153,5 @@ void blake2sp_final( blake2sp_state *S, byte *digest )
|
||||||
|
|
||||||
blake2s_final( &S->R, digest );
|
blake2s_final( &S->R, digest );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -72,7 +72,7 @@ unrar_err_t CmdExtract::ExtractCurrentFile( bool SkipSolid, bool check_compatibi
|
||||||
Unp->DoUnpack(15,FileCount>1 && Arc.Solid);
|
Unp->DoUnpack(15,FileCount>1 && Arc.Solid);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
Unp->DoUnpack(Arc.FileHead.UnpVer,Arc.FileHead.Flags & LHD_SOLID);
|
Unp->DoUnpack(Arc.FileHead.UnpVer,!!(Arc.FileHead.Flags & LHD_SOLID));
|
||||||
}
|
}
|
||||||
|
|
||||||
// (no need to seek to next file)
|
// (no need to seek to next file)
|
||||||
|
@ -100,7 +100,7 @@ unrar_err_t CmdExtract::ExtractCurrentFile( bool SkipSolid, bool check_compatibi
|
||||||
|
|
||||||
void CmdExtract::UnstoreFile(int64 DestUnpSize)
|
void CmdExtract::UnstoreFile(int64 DestUnpSize)
|
||||||
{
|
{
|
||||||
Buffer.Alloc(Min(DestUnpSize,0x10000));
|
Buffer.Alloc((int)Min(DestUnpSize,0x10000));
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
unsigned int Code=DataIO.UnpRead(&Buffer[0],(uint)Buffer.Size());
|
unsigned int Code=DataIO.UnpRead(&Buffer[0],(uint)Buffer.Size());
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* Contents: model description and encoding/decoding routines *
|
* Contents: model description and encoding/decoding routines *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
static const int MAX_O=64; /* maximum allowed model order */
|
static const int MAX_O=64; /* maximum allowed model order */
|
||||||
const uint TOP=1 << 24, BOT=1 << 15;
|
const uint TOP=1 << 24, BOT=1 << 15;
|
||||||
|
|
||||||
|
@ -615,3 +617,5 @@ int ModelPPM::DecodeChar()
|
||||||
ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
|
ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
|
||||||
return(Symbol);
|
return(Symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -19,3 +19,38 @@ wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW,size_t DestS
|
||||||
|
|
||||||
return(DestW);
|
return(DestW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnixSlashToDos(const char *SrcName, char *DestName, size_t MaxLength)
|
||||||
|
{
|
||||||
|
size_t Copied = 0;
|
||||||
|
for (; Copied<MaxLength - 1 && SrcName[Copied] != 0; Copied++)
|
||||||
|
DestName[Copied] = SrcName[Copied] == '/' ? '\\' : SrcName[Copied];
|
||||||
|
DestName[Copied] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DosSlashToUnix(const char *SrcName, char *DestName, size_t MaxLength)
|
||||||
|
{
|
||||||
|
size_t Copied = 0;
|
||||||
|
for (; Copied<MaxLength - 1 && SrcName[Copied] != 0; Copied++)
|
||||||
|
DestName[Copied] = SrcName[Copied] == '\\' ? '/' : SrcName[Copied];
|
||||||
|
DestName[Copied] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UnixSlashToDos(const wchar *SrcName, wchar *DestName, size_t MaxLength)
|
||||||
|
{
|
||||||
|
size_t Copied = 0;
|
||||||
|
for (; Copied<MaxLength - 1 && SrcName[Copied] != 0; Copied++)
|
||||||
|
DestName[Copied] = SrcName[Copied] == '/' ? '\\' : SrcName[Copied];
|
||||||
|
DestName[Copied] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DosSlashToUnix(const wchar *SrcName, wchar *DestName, size_t MaxLength)
|
||||||
|
{
|
||||||
|
size_t Copied = 0;
|
||||||
|
for (; Copied<MaxLength - 1 && SrcName[Copied] != 0; Copied++)
|
||||||
|
DestName[Copied] = SrcName[Copied] == '\\' ? '/' : SrcName[Copied];
|
||||||
|
DestName[Copied] = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -174,6 +174,10 @@ void cleandata(void *data,size_t size);
|
||||||
|
|
||||||
//// pathfn.hpp
|
//// pathfn.hpp
|
||||||
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW,size_t DestSize);
|
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW,size_t DestSize);
|
||||||
|
void UnixSlashToDos(const char *SrcName, char *DestName, size_t MaxLength);
|
||||||
|
void DosSlashToUnix(const char *SrcName, char *DestName, size_t MaxLength);
|
||||||
|
void UnixSlashToDos(const wchar *SrcName, wchar *DestName, size_t MaxLength);
|
||||||
|
void DosSlashToUnix(const wchar *SrcName, wchar *DestName, size_t MaxLength);
|
||||||
|
|
||||||
//// rar.hpp
|
//// rar.hpp
|
||||||
class Unpack;
|
class Unpack;
|
||||||
|
|
|
@ -403,7 +403,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,uint CodeSize)
|
||||||
break;
|
break;
|
||||||
case VM_CALL:
|
case VM_CALL:
|
||||||
R[7]-=4;
|
R[7]-=4;
|
||||||
SET_VALUE(false,(uint *)&Mem[R[7]&VM_MEMMASK],Cmd-PreparedCode+1);
|
SET_VALUE(false,(uint *)&Mem[R[7]&VM_MEMMASK],(uint)(Cmd-PreparedCode+1));
|
||||||
SET_IP(GET_VALUE(false,Op1));
|
SET_IP(GET_VALUE(false,Op1));
|
||||||
continue;
|
continue;
|
||||||
case VM_NOT:
|
case VM_NOT:
|
||||||
|
@ -512,7 +512,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,uint CodeSize)
|
||||||
uint Result=GET_UINT32(Value1+GET_VALUE(Cmd->ByteMode,Op2)+FC);
|
uint Result=GET_UINT32(Value1+GET_VALUE(Cmd->ByteMode,Op2)+FC);
|
||||||
if (Cmd->ByteMode)
|
if (Cmd->ByteMode)
|
||||||
Result&=0xff;
|
Result&=0xff;
|
||||||
Flags=(Result<Value1 || Result==Value1 && FC)|(Result==0 ? VM_FZ:(Result&VM_FS));
|
Flags=(Result<Value1 || (Result==Value1 && FC))|(Result==0 ? VM_FZ:(Result&VM_FS));
|
||||||
SET_VALUE(Cmd->ByteMode,Op1,Result);
|
SET_VALUE(Cmd->ByteMode,Op1,Result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -523,7 +523,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,uint CodeSize)
|
||||||
uint Result=GET_UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2)-FC);
|
uint Result=GET_UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2)-FC);
|
||||||
if (Cmd->ByteMode)
|
if (Cmd->ByteMode)
|
||||||
Result&=0xff;
|
Result&=0xff;
|
||||||
Flags=(Result>Value1 || Result==Value1 && FC)|(Result==0 ? VM_FZ:(Result&VM_FS));
|
Flags=(Result>Value1 || (Result==Value1 && FC))|(Result==0 ? VM_FZ:(Result&VM_FS));
|
||||||
SET_VALUE(Cmd->ByteMode,Op1,Result);
|
SET_VALUE(Cmd->ByteMode,Op1,Result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -807,6 +807,8 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
|
||||||
case VM_CMP:
|
case VM_CMP:
|
||||||
Cmd->OpCode=Cmd->ByteMode ? VM_CMPB:VM_CMPD;
|
Cmd->OpCode=Cmd->ByteMode ? VM_CMPB:VM_CMPD;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
if ((VM_CmdFlags[Cmd->OpCode] & VMCF_CHFLAGS)==0)
|
if ((VM_CmdFlags[Cmd->OpCode] & VMCF_CHFLAGS)==0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -850,6 +852,8 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
|
||||||
case VM_NEG:
|
case VM_NEG:
|
||||||
Cmd->OpCode=Cmd->ByteMode ? VM_NEGB:VM_NEGD;
|
Cmd->OpCode=Cmd->ByteMode ? VM_NEGB:VM_NEGD;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ wchar etoupperw(wchar ch)
|
||||||
{
|
{
|
||||||
if (ch=='i')
|
if (ch=='i')
|
||||||
return('I');
|
return('I');
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(_MSC_VER)
|
||||||
return(toupper(ch));
|
return(toupper(ch));
|
||||||
#else
|
#else
|
||||||
return(toupperw(ch));
|
return(toupperw(ch));
|
||||||
|
@ -234,7 +234,7 @@ bool LowAscii(const wchar *Str)
|
||||||
|
|
||||||
int wcsicompc(const wchar *Str1,const wchar *Str2)
|
int wcsicompc(const wchar *Str1,const wchar *Str2)
|
||||||
{
|
{
|
||||||
#if defined(_UNIX)
|
#if defined(_UNIX) || defined(_MSC_VER)
|
||||||
return my_wcscmp(Str1,Str2);
|
return my_wcscmp(Str1,Str2);
|
||||||
#else
|
#else
|
||||||
return wcsicomp(Str1,Str2);
|
return wcsicomp(Str1,Str2);
|
||||||
|
@ -247,7 +247,11 @@ char* strncpyz(char *dest, const char *src, size_t maxlen)
|
||||||
{
|
{
|
||||||
if (maxlen>0)
|
if (maxlen>0)
|
||||||
{
|
{
|
||||||
strncpy(dest,src,maxlen-1);
|
#if _MSC_VER >= 1300
|
||||||
|
strcpy_s(dest,maxlen-1,src);
|
||||||
|
#else
|
||||||
|
strncpy(dest,src,maxlen-1);
|
||||||
|
#endif
|
||||||
dest[maxlen-1]=0;
|
dest[maxlen-1]=0;
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
|
@ -273,7 +277,11 @@ char* strncatz(char* dest, const char* src, size_t maxlen)
|
||||||
{
|
{
|
||||||
size_t Length = strlen(dest);
|
size_t Length = strlen(dest);
|
||||||
if (Length + 1 < maxlen)
|
if (Length + 1 < maxlen)
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
strcat_s(dest, maxlen - Length - 1, src);
|
||||||
|
#else
|
||||||
strncat(dest, src, maxlen - Length - 1);
|
strncat(dest, src, maxlen - Length - 1);
|
||||||
|
#endif
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,9 +105,9 @@ void SubAllocator::InitSubAllocator()
|
||||||
int i, k;
|
int i, k;
|
||||||
memset(FreeList,0,sizeof(FreeList));
|
memset(FreeList,0,sizeof(FreeList));
|
||||||
pText=HeapStart;
|
pText=HeapStart;
|
||||||
uint Size2=FIXED_UNIT_SIZE*(SubAllocatorSize/8/FIXED_UNIT_SIZE*7);
|
uint Size2=(uint)(FIXED_UNIT_SIZE*(SubAllocatorSize/8/FIXED_UNIT_SIZE*7));
|
||||||
uint RealSize2=Size2/FIXED_UNIT_SIZE*UNIT_SIZE;
|
uint RealSize2=Size2/FIXED_UNIT_SIZE*UNIT_SIZE;
|
||||||
uint Size1=SubAllocatorSize-Size2;
|
uint Size1=(uint)(SubAllocatorSize-Size2);
|
||||||
uint RealSize1=Size1/FIXED_UNIT_SIZE*UNIT_SIZE+Size1%FIXED_UNIT_SIZE;
|
uint RealSize1=Size1/FIXED_UNIT_SIZE*UNIT_SIZE+Size1%FIXED_UNIT_SIZE;
|
||||||
#ifdef STRICT_ALIGNMENT_REQUIRED
|
#ifdef STRICT_ALIGNMENT_REQUIRED
|
||||||
if (Size1%FIXED_UNIT_SIZE!=0)
|
if (Size1%FIXED_UNIT_SIZE!=0)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "rar.hpp"
|
#include "rar.hpp"
|
||||||
|
|
||||||
#ifdef _WIN_ALL
|
#ifdef _WIN_ALL
|
||||||
|
#include <Windows.h>
|
||||||
RarTime& RarTime::operator =(FILETIME &ft)
|
RarTime& RarTime::operator =(FILETIME &ft)
|
||||||
{
|
{
|
||||||
_ULARGE_INTEGER ul = {ft.dwLowDateTime, ft.dwHighDateTime};
|
_ULARGE_INTEGER ul = {ft.dwLowDateTime, ft.dwHighDateTime};
|
||||||
|
@ -42,30 +43,8 @@ void RarTime::GetLocal(RarLocalTime *lt)
|
||||||
GetWin32(&ft);
|
GetWin32(&ft);
|
||||||
FILETIME lft;
|
FILETIME lft;
|
||||||
|
|
||||||
if (WinNT() < WNT_VISTA)
|
// SystemTimeToTzSpecificLocalTime based code produces 1 hour error on XP.
|
||||||
{
|
FileTimeToLocalFileTime(&ft,&lft);
|
||||||
// SystemTimeToTzSpecificLocalTime based code produces 1 hour error on XP.
|
|
||||||
FileTimeToLocalFileTime(&ft,&lft);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We use these functions instead of FileTimeToLocalFileTime according to
|
|
||||||
// MSDN recommendation: "To account for daylight saving time
|
|
||||||
// when converting a file time to a local time ..."
|
|
||||||
SYSTEMTIME st1,st2;
|
|
||||||
FileTimeToSystemTime(&ft,&st1);
|
|
||||||
SystemTimeToTzSpecificLocalTime(NULL,&st1,&st2);
|
|
||||||
SystemTimeToFileTime(&st2,&lft);
|
|
||||||
|
|
||||||
// Correct precision loss (low 4 decimal digits) in FileTimeToSystemTime.
|
|
||||||
FILETIME rft;
|
|
||||||
SystemTimeToFileTime(&st1,&rft);
|
|
||||||
int64 Corrected=INT32TO64(ft.dwHighDateTime,ft.dwLowDateTime)-
|
|
||||||
INT32TO64(rft.dwHighDateTime,rft.dwLowDateTime)+
|
|
||||||
INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime);
|
|
||||||
lft.dwLowDateTime=(DWORD)Corrected;
|
|
||||||
lft.dwHighDateTime=(DWORD)(Corrected>>32);
|
|
||||||
}
|
|
||||||
|
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
FileTimeToSystemTime(&lft,&st);
|
FileTimeToSystemTime(&lft,&st);
|
||||||
|
@ -91,8 +70,8 @@ void RarTime::GetLocal(RarLocalTime *lt)
|
||||||
|
|
||||||
// Calculate the time reminder, which is the part of time smaller
|
// Calculate the time reminder, which is the part of time smaller
|
||||||
// than 1 second, represented in 100-nanosecond intervals.
|
// than 1 second, represented in 100-nanosecond intervals.
|
||||||
lt->Reminder=INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime)-
|
lt->Reminder=int32to64(lft.dwHighDateTime,lft.dwLowDateTime)-
|
||||||
INT32TO64(zft.dwHighDateTime,zft.dwLowDateTime);
|
int32to64(zft.dwHighDateTime,zft.dwLowDateTime);
|
||||||
#else
|
#else
|
||||||
time_t ut=GetUnix();
|
time_t ut=GetUnix();
|
||||||
struct tm *t;
|
struct tm *t;
|
||||||
|
@ -131,28 +110,8 @@ void RarTime::SetLocal(RarLocalTime *lt)
|
||||||
|
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
|
|
||||||
if (WinNT() < WNT_VISTA)
|
// TzSpecificLocalTimeToSystemTime based code produces 1 hour error on XP.
|
||||||
{
|
LocalFileTimeToFileTime(&lft,&ft);
|
||||||
// TzSpecificLocalTimeToSystemTime based code produces 1 hour error on XP.
|
|
||||||
LocalFileTimeToFileTime(&lft,&ft);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Reverse procedure which we do in GetLocal.
|
|
||||||
SYSTEMTIME st1,st2;
|
|
||||||
FileTimeToSystemTime(&lft,&st2);
|
|
||||||
TzSpecificLocalTimeToSystemTime(NULL,&st2,&st1);
|
|
||||||
SystemTimeToFileTime(&st1,&ft);
|
|
||||||
|
|
||||||
// Correct precision loss (low 4 decimal digits) in FileTimeToSystemTime.
|
|
||||||
FILETIME rft;
|
|
||||||
SystemTimeToFileTime(&st2,&rft);
|
|
||||||
int64 Corrected=INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime)-
|
|
||||||
INT32TO64(rft.dwHighDateTime,rft.dwLowDateTime)+
|
|
||||||
INT32TO64(ft.dwHighDateTime,ft.dwLowDateTime);
|
|
||||||
ft.dwLowDateTime=(DWORD)Corrected;
|
|
||||||
ft.dwHighDateTime=(DWORD)(Corrected>>32);
|
|
||||||
}
|
|
||||||
|
|
||||||
*this=ft;
|
*this=ft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#define _RAR_TIMEFN_
|
#define _RAR_TIMEFN_
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifdef _WIN_ALL
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct RarLocalTime
|
struct RarLocalTime
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "rar.hpp"
|
#include "rar.hpp"
|
||||||
|
|
||||||
|
#define _RAR_UNPACK_CPP_
|
||||||
|
|
||||||
#include "coder.cpp"
|
#include "coder.cpp"
|
||||||
#include "suballoc.cpp"
|
#include "suballoc.cpp"
|
||||||
#include "model.cpp"
|
#include "model.cpp"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
#define STARTL1 2
|
#define STARTL1 2
|
||||||
static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
|
static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
|
||||||
0xee00,0xf000,0xf200,0xf200,0xffff};
|
0xee00,0xf000,0xf200,0xf200,0xffff};
|
||||||
|
@ -479,3 +481,5 @@ uint Unpack::DecodeNum(uint Num,uint StartPos,uint *DecTab,uint *PosTab)
|
||||||
Inp.faddbits(StartPos);
|
Inp.faddbits(StartPos);
|
||||||
return(((Num-(I ? DecTab[I-1]:0))>>(16-StartPos))+PosTab[StartPos]);
|
return(((Num-(I ? DecTab[I-1]:0))>>(16-StartPos))+PosTab[StartPos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "rar.hpp"
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
void Unpack::CopyString20(uint Length,uint Distance)
|
void Unpack::CopyString20(uint Length,uint Distance)
|
||||||
{
|
{
|
||||||
|
@ -368,3 +368,5 @@ byte Unpack::DecodeAudio(int Delta)
|
||||||
}
|
}
|
||||||
return((byte)Ch);
|
return((byte)Ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
// We use it instead of direct PPM.DecodeChar call to be sure that
|
// We use it instead of direct PPM.DecodeChar call to be sure that
|
||||||
// we reset PPM structures in case of corrupt data. It is important,
|
// we reset PPM structures in case of corrupt data. It is important,
|
||||||
// because these structures can be invalid after PPM.DecodeChar returned -1.
|
// because these structures can be invalid after PPM.DecodeChar returned -1.
|
||||||
|
@ -834,3 +836,5 @@ void Unpack::InitFilters30()
|
||||||
delete PrgStack[I];
|
delete PrgStack[I];
|
||||||
PrgStack.Reset();
|
PrgStack.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
void Unpack::Unpack5(bool Solid)
|
void Unpack::Unpack5(bool Solid)
|
||||||
{
|
{
|
||||||
FileExtracted=true;
|
FileExtracted=true;
|
||||||
|
@ -646,3 +648,5 @@ void Unpack::InitFilters()
|
||||||
{
|
{
|
||||||
Filters.Reset();
|
Filters.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
FragmentedWindow::FragmentedWindow()
|
FragmentedWindow::FragmentedWindow()
|
||||||
{
|
{
|
||||||
memset(Mem,0,sizeof(Mem));
|
memset(Mem,0,sizeof(Mem));
|
||||||
|
@ -101,3 +103,5 @@ size_t FragmentedWindow::GetBlockSize(size_t StartPos,size_t RequiredSize)
|
||||||
return Min(MemSize[I]-StartPos,RequiredSize);
|
return Min(MemSize[I]-StartPos,RequiredSize);
|
||||||
return 0; // Must never be here.
|
return 0; // Must never be here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef RAR_COMMON_HPP
|
||||||
|
|
||||||
inline void Unpack::InsertOldDist(uint Distance)
|
inline void Unpack::InsertOldDist(uint Distance)
|
||||||
{
|
{
|
||||||
OldDist[3]=OldDist[2];
|
OldDist[3]=OldDist[2];
|
||||||
|
@ -140,3 +142,5 @@ inline uint Unpack::SlotToLength(BitInput &Inp,uint Slot)
|
||||||
}
|
}
|
||||||
return Length;
|
return Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -76,7 +76,7 @@ extern "C" {
|
||||||
assert( !p->data_ );
|
assert( !p->data_ );
|
||||||
|
|
||||||
unrar_pos_t size = unrar_info( p )->size;
|
unrar_pos_t size = unrar_info( p )->size;
|
||||||
p->own_data_ = malloc( size ? size : 1 );
|
p->own_data_ = malloc( size ? (size_t)size : 1 );
|
||||||
if ( !p->own_data_ )
|
if ( !p->own_data_ )
|
||||||
return unrar_err_memory;
|
return unrar_err_memory;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ int ComprDataIO::UnpRead( byte* out, uint count )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( count > (uint) UnpPackedSize )
|
if ( count > (uint) UnpPackedSize )
|
||||||
count = UnpPackedSize;
|
count = (uint) UnpPackedSize;
|
||||||
|
|
||||||
int result = Read( out, count );
|
int result = Read( out, count );
|
||||||
UnpPackedSize -= result;
|
UnpPackedSize -= result;
|
||||||
|
|
|
@ -10,7 +10,7 @@ extern "C" {
|
||||||
FILE* file = (FILE*) user_data;
|
FILE* file = (FILE*) user_data;
|
||||||
|
|
||||||
// most of the time, seeking won't be necessary
|
// most of the time, seeking won't be necessary
|
||||||
if ( pos != ftell( file ) && fseek( file, pos, SEEK_SET ) != 0 )
|
if ( pos != ftell( file ) && fseek( file, (long)pos, SEEK_SET ) != 0 )
|
||||||
return unrar_err_corrupt;
|
return unrar_err_corrupt;
|
||||||
|
|
||||||
*count = (int) fread( out, 1, *count, file );
|
*count = (int) fread( out, 1, *count, file );
|
||||||
|
@ -30,8 +30,13 @@ static void unrar_close_file( void* user_data )
|
||||||
unrar_err_t unrar_open( unrar_t** arc_out, const char path [] )
|
unrar_err_t unrar_open( unrar_t** arc_out, const char path [] )
|
||||||
{
|
{
|
||||||
*arc_out = NULL;
|
*arc_out = NULL;
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
FILE* file = NULL;
|
||||||
|
fopen_s(&file, path, "rb");
|
||||||
|
#else
|
||||||
FILE* file = fopen( path, "rb" );
|
FILE* file = fopen( path, "rb" );
|
||||||
|
#endif
|
||||||
if ( file == NULL )
|
if ( file == NULL )
|
||||||
return unrar_err_open;
|
return unrar_err_open;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue