hl2_src-leak-2017/src/utils/tfstats/binaryresource.h
BotoX 60f625f414 import hl2_src from full.7z
source: magnet:?xt=urn:btih:21DDA6847DDE983F2F8063739249D2D1D09A5DDA
2020-12-25 16:26:23 +01:00

49 lines
951 B
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#ifndef BINARYRESOURCE_H
#define BINARYRESOURCE_H
#ifdef WIN32
#pragma once
#endif
#include <string>
#include <stdio.h>
#include "util.h"
class CBinaryResource
{
private:
std::string filename;
size_t numBytes;
unsigned char* pData;
public:
CBinaryResource(char* name, size_t bytes,unsigned char* data)
:filename(name),numBytes(bytes),pData(data)
{}
bool writeOut()
{
FILE* f=fopen(filename.c_str(),"wb");
if (!f)
return false;
fwrite(pData,1,numBytes,f);
fclose(f);
#ifndef WIN32
chmod(filename.c_str(),PERMIT);
#endif
return true;
}
};
#endif // BINARYRESOURCE_H