Remove static direct i/o buffer & blocksize cfg option.
This commit is contained in:
parent
ad85c15f07
commit
33e8f4d76b
|
@ -127,7 +127,7 @@
|
|||
#define OS OS_ANDROID
|
||||
#define IS_ANDROID 1
|
||||
|
||||
#elif defined(_LINUX)
|
||||
#elif defined(__linux__)
|
||||
#define OS OS_LINUX
|
||||
#define IS_LINUX 1
|
||||
|
||||
|
|
|
@ -98,28 +98,9 @@ iFCOProp::CmpResult iSignature::Compare(const iFCOProp* rhs, Op op) const
|
|||
return (op == iFCOProp::OP_NE) ? iFCOProp::CMP_TRUE : iFCOProp::CMP_FALSE;
|
||||
}
|
||||
|
||||
bool cArchiveSigGen::s_hex = false;
|
||||
int32 cArchiveSigGen::s_blocks = 1;
|
||||
int32 cArchiveSigGen::s_bytes = iSignature::SUGGESTED_BLOCK_SIZE;
|
||||
byte* cArchiveSigGen::s_buf = 0;
|
||||
byte* cArchiveSigGen::s_base = 0;
|
||||
bool cArchiveSigGen::s_hex = false;
|
||||
bool cArchiveSigGen::s_direct = false;
|
||||
|
||||
|
||||
void cArchiveSigGen::SetBlocks( int32 n )
|
||||
{
|
||||
cDebug d("cArchiveSigGen::SetBlocks");
|
||||
|
||||
s_blocks=n;
|
||||
d.TraceDebug("Num blocks = %u\n", s_blocks);
|
||||
s_base = new byte[iSignature::SUGGESTED_BLOCK_SIZE * (s_blocks+2)];
|
||||
unsigned long mod = (unsigned long)s_base % iSignature::SUGGESTED_BLOCK_SIZE;
|
||||
unsigned long offset = (iSignature::SUGGESTED_BLOCK_SIZE - mod);
|
||||
d.TraceDebug("mod = %u | offset = %u\n", mod, offset);
|
||||
s_buf = s_base + offset;
|
||||
s_bytes = iSignature::SUGGESTED_BLOCK_SIZE * s_blocks;
|
||||
}
|
||||
|
||||
void cArchiveSigGen::AddSig( iSignature* pSig )
|
||||
{
|
||||
mSigList.push_back( pSig );
|
||||
|
@ -127,12 +108,18 @@ void cArchiveSigGen::AddSig( iSignature* pSig )
|
|||
|
||||
void cArchiveSigGen::CalculateSignatures( cArchive& a )
|
||||
{
|
||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE * 2];
|
||||
int cbRead;
|
||||
container_type::size_type i;
|
||||
byte* pBuf = abBuf;
|
||||
|
||||
byte* pBuf = s_buf ? s_buf : abBuf;
|
||||
|
||||
if (s_direct)
|
||||
{
|
||||
unsigned long mod = (unsigned long)abBuf % iSignature::SUGGESTED_BLOCK_SIZE;
|
||||
unsigned long offset = (iSignature::SUGGESTED_BLOCK_SIZE - mod);
|
||||
pBuf = abBuf + offset;
|
||||
}
|
||||
|
||||
// init hash
|
||||
for( i = 0; i < mSigList.size(); i++ )
|
||||
mSigList[i]->Init();
|
||||
|
@ -140,12 +127,12 @@ void cArchiveSigGen::CalculateSignatures( cArchive& a )
|
|||
// hash data
|
||||
do
|
||||
{
|
||||
cbRead = a.ReadBlob( pBuf, s_bytes );
|
||||
cbRead = a.ReadBlob( pBuf, iSignature::SUGGESTED_BLOCK_SIZE );
|
||||
|
||||
for( i = 0; i < mSigList.size(); i++ )
|
||||
mSigList[i]->Update( pBuf, cbRead );
|
||||
}
|
||||
while( cbRead == s_bytes );
|
||||
while( cbRead == iSignature::SUGGESTED_BLOCK_SIZE );
|
||||
|
||||
// finalize hash
|
||||
for( i = 0; i < mSigList.size(); i++ )
|
||||
|
|
|
@ -156,7 +156,6 @@ public:
|
|||
static bool Hex();
|
||||
static void SetHex(bool);
|
||||
|
||||
static void SetBlocks( int32 n );
|
||||
static bool UseDirectIO() { return s_direct; }
|
||||
static void SetUseDirectIO( bool b ) { s_direct = b; }
|
||||
|
||||
|
@ -168,12 +167,8 @@ private:
|
|||
typedef std::vector< iSignature* > container_type;
|
||||
container_type mSigList;
|
||||
|
||||
static bool s_hex;
|
||||
static int32 s_blocks;
|
||||
static int32 s_bytes;
|
||||
static byte* s_buf;
|
||||
static byte* s_base;
|
||||
static bool s_direct;
|
||||
static bool s_hex;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -444,7 +444,6 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
|
|||
pModeInfo->mbCrossFileSystems = false;
|
||||
}
|
||||
|
||||
int blocks = 0;
|
||||
if (cf.Lookup(TSTRING(_T("HASH_DIRECT_IO")), str))
|
||||
{
|
||||
#if SUPPORTS_DIRECT_IO
|
||||
|
@ -452,7 +451,6 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
|
|||
{
|
||||
pModeInfo->mbDirectIO = true;
|
||||
cArchiveSigGen::SetUseDirectIO(true);
|
||||
blocks = 1;
|
||||
}
|
||||
#else
|
||||
throw eTWDirectIONotSupported();
|
||||
|
@ -460,15 +458,6 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
|
|||
|
||||
}
|
||||
|
||||
if (cf.Lookup(TSTRING(_T("HASH_BLOCKS")), str))
|
||||
{
|
||||
int requested_blocks = _ttoi(str.c_str());
|
||||
if (requested_blocks > 0)
|
||||
blocks = requested_blocks;
|
||||
}
|
||||
|
||||
if( blocks > 0 )
|
||||
cArchiveSigGen::SetBlocks(blocks);
|
||||
//
|
||||
// turn all of the file names into full paths (they're relative to the exe dir)
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue