From 78cbd84a0068db09b6d08ff14a316800ad9be89a Mon Sep 17 00:00:00 2001 From: weidai Date: Tue, 15 Apr 2003 00:38:48 +0000 Subject: fix bug in Grouper add RIPEMD-???, Whirlpool, Shacal2, Camellia, Two-Track MAC (Kevin Springle) change ChannelSwitch to allow non-blocking input (denis bider) change Redirector to allow more options (denis bider) fix MaurerRandomnessTest optimize MD2 (Kevin Springle) git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@55 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- files.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'files.cpp') diff --git a/files.cpp b/files.cpp index 2b42010..fc32b4b 100644 --- a/files.cpp +++ b/files.cpp @@ -16,10 +16,12 @@ void Files_TestInstantiations() void FileStore::StoreInitialize(const NameValuePairs ¶meters) { + m_file.close(); + m_file.clear(); const char *fileName; - if (parameters.GetValue("InputFileName", fileName)) + if (parameters.GetValue(Name::InputFileName(), fileName)) { - ios::openmode binary = parameters.GetValueWithDefault("InputBinaryMode", true) ? ios::binary : ios::openmode(0); + ios::openmode binary = parameters.GetValueWithDefault(Name::InputBinaryMode(), true) ? ios::binary : ios::openmode(0); m_file.open(fileName, ios::in | binary); if (!m_file) throw OpenErr(fileName); @@ -28,7 +30,7 @@ void FileStore::StoreInitialize(const NameValuePairs ¶meters) else { m_stream = NULL; - parameters.GetValue("InputStreamPointer", m_stream); + parameters.GetValue(Name::InputStreamPointer(), m_stream); } m_waiting = false; } @@ -137,12 +139,19 @@ unsigned int FileStore::CopyRangeTo2(BufferedTransformation &target, unsigned lo return 0; } +unsigned long FileStore::Skip(unsigned long skipMax) +{ + unsigned long oldPos = m_stream->tellg(); + m_stream->seekg(skipMax, ios_base::cur); + return (unsigned long)m_stream->tellg() - oldPos; +} + void FileSink::IsolatedInitialize(const NameValuePairs ¶meters) { const char *fileName; - if (parameters.GetValue("OutputFileName", fileName)) + if (parameters.GetValue(Name::OutputFileName(), fileName)) { - ios::openmode binary = parameters.GetValueWithDefault("OutputBinaryMode", true) ? ios::binary : ios::openmode(0); + ios::openmode binary = parameters.GetValueWithDefault(Name::OutputBinaryMode(), true) ? ios::binary : ios::openmode(0); m_file.open(fileName, ios::out | ios::trunc | binary); if (!m_file) throw OpenErr(fileName); @@ -151,7 +160,7 @@ void FileSink::IsolatedInitialize(const NameValuePairs ¶meters) else { m_stream = NULL; - parameters.GetValue("OutputStreamPointer", m_stream); + parameters.GetValue(Name::OutputStreamPointer(), m_stream); } } -- cgit v1.2.1