Esempio n. 1
0
bool File::RawSeek(Int64 Offset,int Method)
{
  if (hFile==BAD_HANDLE)
    return(true);
  if (!is64plus(Offset) && Method!=SEEK_SET)
  {
    Offset=(Method==SEEK_CUR ? Tell():FileLength())+Offset;
    Method=SEEK_SET;
  }
/*#ifdef _WIN_32
  LONG HighDist=int64to32(Offset>>32);
  if (SetFilePointer(hFile,int64to32(Offset),&HighDist,Method)==0xffffffff &&
      GetLastError()!=NO_ERROR)
    return(false);
#else*/
  LastWrite=false;
#ifdef _LARGEFILE_SOURCE
  if (fseeko(hFile,Offset,Method)!=0)
#else
  if (fseek(hFile,int64to32(Offset),Method)!=0)
#endif
    return(false);
//#endif
  return(true);
}
Esempio n. 2
0
void Unpack::Unpack20(bool Solid)
{
	const
	static unsigned char LDecode[]={0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
	const
	static unsigned char LBits[]=  {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5};
	const
	static int DDecode[]={0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576,32768U,49152U,65536,98304,131072,196608,262144,327680,393216,458752,524288,589824,655360,720896,786432,851968,917504,983040};
	const
	static unsigned char DBits[]=  {0,0,0,0,1,1,2, 2, 3, 3, 4, 4, 5, 5,  6,  6,  7,  7,  8,  8,   9,   9,  10,  10,  11,  11,  12,   12,   13,   13,    14,    14,   15,   15,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16,    16};
	const
	static unsigned char SDDecode[]={0,4,8,16,32,64,128,192};
	const
	static unsigned char SDBits[]=  {2,2,3, 4, 5, 6,  6,  6};
	unsigned int Bits;

	if (Suspended)
		UnpPtr=WrPtr;
	else
	{
		UnpInitData(Solid);
		if (!UnpReadBuf())
			return;
		if (!Solid)
			if (!ReadTables20())
				return;
		--DestUnpSize;
	}

	while (is64plus(DestUnpSize))
	{
		UnpPtr&=MAXWINMASK;

		if (InAddr>ReadTop-30)
			if (!UnpReadBuf())
				break;
		if (((WrPtr-UnpPtr) & MAXWINMASK)<270 && WrPtr!=UnpPtr)
		{
			OldUnpWriteBuf();
			if (Suspended)
				return;
		}
		if (UnpAudioBlock)
		{
			int AudioNumber=DecodeNumber((struct Decode *)&MD[UnpCurChannel]);

			if (AudioNumber==256)
			{
				if (!ReadTables20())
					break;
				continue;
			}
			Window[UnpPtr++]=DecodeAudio(AudioNumber);
			if (++UnpCurChannel==UnpChannels)
				UnpCurChannel=0;
			--DestUnpSize;
			continue;
		}

		int Number=DecodeNumber((struct Decode *)&LD);
		if (Number<256)
		{
			Window[UnpPtr++]=(byte)Number;
			--DestUnpSize;
			continue;
		}
		if (Number>269)
		{
			int Length=LDecode[Number-=270]+3;
			if ((Bits=LBits[Number])>0)
			{
				Length+=getbits()>>(16-Bits);
				addbits(Bits);
			}

			int DistNumber=DecodeNumber((struct Decode *)&DD);
			unsigned int Distance=DDecode[DistNumber]+1;
			if ((Bits=DBits[DistNumber])>0)
			{
				Distance+=getbits()>>(16-Bits);
				addbits(Bits);
			}