cleanup, assert -> ASSERT

This commit is contained in:
Glenn Maynard
2005-05-19 21:34:47 +00:00
parent aa5c8699fb
commit 93ff013321
+12 -13
View File
@@ -5,14 +5,13 @@
#include "crypto51/files.h" #include "crypto51/files.h"
void RageFileStore::StoreInitialize(const NameValuePairs &parameters) void RageFileStore::StoreInitialize(const NameValuePairs &parameters)
{ {
const char *fileName; const char *fileName;
if (parameters.GetValue("InputFileName", fileName)) if( parameters.GetValue("InputFileName", fileName) )
{ {
if( !m_file.Open(fileName, RageFile::READ) ) if( !m_file.Open(fileName, RageFile::READ) )
throw OpenErr(fileName); throw OpenErr( fileName );
} }
else else
{ {
@@ -40,7 +39,7 @@ unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned
unsigned long size=transferBytes; unsigned long size=transferBytes;
transferBytes = 0; transferBytes = 0;
if (m_waiting) if( m_waiting )
goto output; goto output;
while( size && !m_file.AtEOF() ) while( size && !m_file.AtEOF() )
@@ -57,7 +56,7 @@ unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned
output: output:
blockedBytes = target.ChannelPutModifiable2(channel, m_space, m_len, 0, blocking); blockedBytes = target.ChannelPutModifiable2(channel, m_space, m_len, 0, blocking);
m_waiting = blockedBytes > 0; m_waiting = blockedBytes > 0;
if (m_waiting) if( m_waiting )
return blockedBytes; return blockedBytes;
size -= m_len; size -= m_len;
transferBytes += m_len; transferBytes += m_len;
@@ -72,7 +71,7 @@ unsigned int RageFileStore::CopyRangeTo2(BufferedTransformation &target, unsigne
if( !m_file.IsGood() ) if( !m_file.IsGood() )
return 0; return 0;
if (begin == 0 && end == 1) if( begin == 0 && end == 1 )
{ {
int current = m_file.Tell(); int current = m_file.Tell();
byte result; byte result;
@@ -81,7 +80,7 @@ unsigned int RageFileStore::CopyRangeTo2(BufferedTransformation &target, unsigne
if( m_file.AtEOF() ) if( m_file.AtEOF() )
return 0; return 0;
unsigned int blockedBytes = target.ChannelPut(channel, byte(result), blocking); unsigned int blockedBytes = target.ChannelPut( channel, byte(result), blocking );
begin += 1-blockedBytes; begin += 1-blockedBytes;
return blockedBytes; return blockedBytes;
} }
@@ -94,14 +93,14 @@ unsigned int RageFileStore::CopyRangeTo2(BufferedTransformation &target, unsigne
if( newPosition >= m_file.GetFileSize() ) if( newPosition >= m_file.GetFileSize() )
return 0; // don't try to seek beyond the end of file return 0; // don't try to seek beyond the end of file
m_file.Seek(newPosition); m_file.Seek( newPosition );
try try
{ {
assert(!m_waiting); ASSERT( !m_waiting );
unsigned long copyMax = end-begin; unsigned long copyMax = end-begin;
unsigned int blockedBytes = const_cast<RageFileStore *>(this)->TransferTo2(target, copyMax, channel, blocking); unsigned int blockedBytes = const_cast<RageFileStore *>(this)->TransferTo2( target, copyMax, channel, blocking );
begin += copyMax; begin += copyMax;
if (blockedBytes) if( blockedBytes )
{ {
const_cast<RageFileStore *>(this)->m_waiting = false; const_cast<RageFileStore *>(this)->m_waiting = false;
return blockedBytes; return blockedBytes;
@@ -110,11 +109,11 @@ unsigned int RageFileStore::CopyRangeTo2(BufferedTransformation &target, unsigne
catch(...) catch(...)
{ {
m_file.ClearError(); m_file.ClearError();
m_file.Seek(current); m_file.Seek( current );
throw; throw;
} }
m_file.ClearError(); m_file.ClearError();
m_file.Seek(current); m_file.Seek( current );
return 0; return 0;
} }