本文整理汇总了C++中framework::CStream::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ CStream::Write方法的具体用法?C++ CStream::Write怎么用?C++ CStream::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类framework::CStream
的用法示例。
在下文中一共展示了CStream::Write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractCompressed
void CPatchFile::ExtractCompressed(Framework::CStream& outputStream, Framework::CStream& inputStream, uint32 compressedSize)
{
z_stream zStream;
zStream.zalloc = Z_NULL;
zStream.zfree = Z_NULL;
zStream.opaque = Z_NULL;
zStream.avail_in = 0;
zStream.next_in = Z_NULL;
if(inflateInit(&zStream) != Z_OK)
{
throw std::runtime_error("zlib stream initialization error.");
}
const uint32 bufferSize = 0x4000;
uint8 inBuffer[bufferSize];
uint8 outBuffer[bufferSize];
while(1)
{
if(zStream.avail_in == 0)
{
if(compressedSize == 0)
{
//EOF
break;
}
uint32 toRead = std::min<uint32>(bufferSize, compressedSize);
inputStream.Read(inBuffer, toRead);
compressedSize -= toRead;
zStream.avail_in = toRead;
zStream.next_in = inBuffer;
}
zStream.avail_out = bufferSize;
zStream.next_out = outBuffer;
int ret = inflate(&zStream, Z_NO_FLUSH);
if(ret < 0)
{
throw std::runtime_error("Error occured while inflating.");
break;
}
int have = bufferSize - zStream.avail_out;
outputStream.Write(outBuffer, have);
if(ret == Z_STREAM_END)
{
break;
}
}
inflateEnd(&zStream);
}
示例2: ExtractUncompressed
void CPatchFile::ExtractUncompressed(Framework::CStream& outputStream, Framework::CStream& inputStream, uint32 compressedSize)
{
const uint32 bufferSize = 0x4000;
uint8 buffer[bufferSize];
while(compressedSize != 0)
{
uint32 toRead = std::min<uint32>(bufferSize, compressedSize);
inputStream.Read(buffer, toRead);
outputStream.Write(buffer, toRead);
compressedSize -= toRead;
}
}
示例3: WriteDialogTemplate
void CDialog::WriteDialogTemplate(DIALOGTEMPLATE& dialog, Framework::CStream& stream)
{
stream.Write16(dialog.dlgVer);
stream.Write16(dialog.signature);
stream.Write32(dialog.helpID);
stream.Write32(dialog.exStyle);
stream.Write32(dialog.style);
stream.Write16(dialog.cDlgItems);
stream.Write16(dialog.x);
stream.Write16(dialog.y);
stream.Write16(dialog.cx);
stream.Write16(dialog.cy);
WriteSzOrOrd(dialog.menu, stream);
WriteSzOrOrd(dialog.windowClass, stream);
WriteString(dialog.title, stream);
stream.Write16(dialog.pointsize);
stream.Write16(dialog.weight);
stream.Write8(dialog.italic);
stream.Write8(dialog.charset);
WriteString(dialog.typeface, stream);
//Pad struct for alignment to DWORD boundary
{
auto currentBytePos = stream.Tell() & 0x3;
if(currentBytePos != 0)
{
for(unsigned int i = 0; i < (4 - currentBytePos); i++)
{
stream.Write8(0);
}
}
assert((stream.Tell() & 0x03) == 0);
}
if(!dialog.dialogItemData.empty())
{
stream.Write(dialog.dialogItemData.data(), dialog.dialogItemData.size());
}
}
示例4: Write
uint32 CIoman::Write(uint32 handle, uint32 size, const void* buffer)
{
CLog::GetInstance().Print(LOG_NAME, "Write(handle = %d, size = 0x%X, buffer = ptr);\r\n", handle, size);
uint32 result = 0xFFFFFFFF;
try
{
Framework::CStream* stream = GetFileStream(handle);
result = static_cast<uint32>(stream->Write(buffer, size));
if((handle == FID_STDOUT) || (handle == FID_STDERR))
{
//Force flusing stdout and stderr
stream->Flush();
}
}
catch(const std::exception& except)
{
if((handle != FID_STDOUT) && (handle != FID_STDERR))
{
CLog::GetInstance().Print(LOG_NAME, "%s: Error occured while trying to write file : %s\r\n", __FUNCTION__, except.what());
}
}
return result;
}