|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Author: Elm� (http://netcult.ch/elmue)
// Date: 01-08-2006
//
// Filename: ExtractStreamT.hpp
//
// - CExtractStreamT<T>
// - CExtractStream
//
// Purpose: This template extracts files from a stream which holds a cabinet file
//
#pragma once
#include "ExtractMemoryT.hpp"
#pragma warning(disable: 4996)
template <class T> class CExtractStreamT : public CExtractMemoryT<T>
{
public:
// Copy the files from the stream which contains a cabinet file
BOOL ExtractStreamW(WCHAR* u16_TargetDir, void* pParam = NULL)
{
// Pass it on to the base class (the file name is a dummy which is not used)
return ExtractFileW(L"*CABINET\\*STREAM", u16_TargetDir, pParam);
}
// Check if the stream contains a valid cabinet file
BOOL IsStreamCabinet(PFDICABINETINFO pfdici = NULL)
{
// Pass it on to the base class (the file name is a dummy which is not used)
return IsCabinetW(L"*CABINET\\*STREAM", pfdici);
}
private:
// Reset the stream pointer to the beginning of the stream
static kMemory* OpenMem(const char* filename, int, int)
{
int Size = CabLib::Extract::OnStreamGetLength();
return new kMemory(0, 0, Size);
}
// Copies a part of the memory from the stream to the buffer.
static int ReadMem(kMemory* pk_Mem, void* buffer, UINT count)
{
// Return the amount of bytes copied
return CabLib::Extract::OnStreamRead(buffer, pk_Mem->s32_Pos, count);
}
// Declare this class as a friend so it can access the private members.
friend class CExtractMemoryT<T>;
};
class CExtractStream : public CExtractStreamT<CExtractStream> {};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.