5 #ifndef CRYPTOPP_IMPORTS 13 #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 14 void Files_TestInstantiations()
28 const char *fileName = NULL;
29 #if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 30 const wchar_t *fileNameWide = NULL;
31 if (!parameters.
GetValue(Name::InputFileNameWide(), fileNameWide))
33 if (!parameters.
GetValue(Name::InputFileName(), fileName))
39 std::ios::openmode binary = parameters.
GetValueWithDefault(Name::InputBinaryMode(),
true) ? std::ios::binary : std::ios::openmode(0);
41 #ifdef CRYPTOPP_UNIX_AVAILABLE 44 fileName = (narrowed =
StringNarrow(fileNameWide)).c_str();
49 m_file->open(fileNameWide, std::ios::in | binary);
56 m_file->open(fileName, std::ios::in | binary);
68 std::streampos current =
m_stream->tellg();
69 std::streampos end =
m_stream->seekg(0, std::ios::end).tellg();
91 size_t spaceSize = 1024;
104 transferBytes +=
m_len;
118 if (begin == 0 && end == 1)
121 if (result == std::char_traits<char>::eof())
125 size_t blockedBytes = target.
ChannelPut(channel,
byte(result), blocking);
126 begin += 1-blockedBytes;
132 std::streampos current =
m_stream->tellg();
133 std::streampos endPosition =
m_stream->seekg(0, std::ios::end).tellg();
134 std::streampos newPosition = current +
static_cast<std::streamoff
>(begin);
136 if (newPosition >= endPosition)
145 lword copyMax = end-begin;
146 size_t blockedBytes =
const_cast<FileStore *
>(
this)->
TransferTo2(target, copyMax, channel, blocking);
172 std::istream::off_type offset;
175 m_stream->seekg(offset, std::ios::cur);
184 const char *fileName = NULL;
185 #if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 186 const wchar_t *fileNameWide = NULL;
187 if (!parameters.
GetValue(Name::OutputFileNameWide(), fileNameWide))
189 if (!parameters.
GetValue(Name::OutputFileName(), fileName))
195 std::ios::openmode binary = parameters.
GetValueWithDefault(Name::OutputBinaryMode(),
true) ? std::ios::binary : std::ios::openmode(0);
197 #ifdef CRYPTOPP_UNIX_AVAILABLE 198 std::string narrowed;
200 fileName = (narrowed =
StringNarrow(fileNameWide)).c_str();
201 #elif (CRYPTOPP_MSC_VERSION >= 1400) 204 m_file->open(fileNameWide, std::ios::out | std::ios::trunc | binary);
211 m_file->open(fileName, std::ios::out | std::ios::trunc | binary);
222 throw Err(
"FileSink: output stream not opened");
235 throw Err(
"FileSink: output stream not opened");
239 std::streamsize
size;
242 m_stream->write((
const char *)inString, size);
244 length -= (size_t)size;
An invalid argument was detected.
bool SafeConvert(T1 from, T2 &to)
Tests whether a conversion from -> to is safe to perform.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
Implementation of Store interface.
#define NAMESPACE_BEGIN(x)
lword MaxRetrievable() const
Provides the number of bytes ready for retrieval.
std::string StringNarrow(const wchar_t *str, bool throwOnError)
Converts a wide character C-string to a multibyte string.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
bool IsolatedFlush(bool hardFlush, bool blocking)
Flushes data buffered by this object, without signal propagation.
bool GetValue(const char *name, T &value) const
Get a named value.
lword Skip(lword skipMax=ULONG_MAX)
Discard skipMax bytes from the output buffer.
Exception thrown when file-based write error is encountered.
Exception thrown when file-based error is encountered.
const T1 UnsignedMin(const T1 &a, const T2 &b)
Safe comparison of values that could be neagtive and incorrectly promoted.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
#define CRYPTOPP_ASSERT(exp)
member_ptr< std::ifstream > m_file
Implementation of Store interface.
Exception thrown when file-based open error is encountered.
uint8_t const size_t const size
#define CRYPTOPP_UNUSED(x)
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Classes providing file-based library services.
std::vector< char * > parameters
void StoreInitialize(const NameValuePairs ¶meters)
byte * HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize)
Create a working space in a BufferedTransformation.
Implementation of Store interface.
Exception thrown when file-based read error is encountered.
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const
Copy bytes from this object to another BufferedTransformation.
Interface for retrieving values given their names.
Exception thrown when file-based open error is encountered.