Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
951 B

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef BINARYRESOURCE_H
  14. #define BINARYRESOURCE_H
  15. #ifdef WIN32
  16. #pragma once
  17. #endif
  18. #include <string>
  19. #include <stdio.h>
  20. #include "util.h"
  21. class CBinaryResource
  22. {
  23. private:
  24. std::string filename;
  25. size_t numBytes;
  26. unsigned char* pData;
  27. public:
  28. CBinaryResource(char* name, size_t bytes,unsigned char* data)
  29. :filename(name),numBytes(bytes),pData(data)
  30. {}
  31. bool writeOut()
  32. {
  33. FILE* f=fopen(filename.c_str(),"wb");
  34. if (!f)
  35. return false;
  36. fwrite(pData,1,numBytes,f);
  37. fclose(f);
  38. #ifndef WIN32
  39. chmod(filename.c_str(),PERMIT);
  40. #endif
  41. return true;
  42. }
  43. };
  44. #endif // BINARYRESOURCE_H