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.

37 lines
1.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: .360 file creation of PCF files
  4. //
  5. //=====================================================================================//
  6. #include "MakeGameData.h"
  7. bool CreateTargetFile_PCF( const char *pSourceName, const char *pTargetName, bool bWriteToZip )
  8. {
  9. DmxHeader_t header;
  10. CDmElement *pRoot;
  11. if ( g_pDataModel->RestoreFromFile( pSourceName, NULL, NULL, &pRoot, CR_DELETE_NEW, &header ) == DMFILEID_INVALID )
  12. {
  13. Msg( "CreateTargetFile_PCF: Error reading file \"%s\"!\n", pSourceName );
  14. return false;
  15. }
  16. const char *pOutFormat = header.formatName;
  17. if ( !g_pDataModel->FindFormatUpdater( pOutFormat ) )
  18. {
  19. pOutFormat = "dmx";
  20. }
  21. CUtlBuffer binaryBuffer;
  22. if ( !g_pDataModel->Serialize( binaryBuffer, "binary", pOutFormat, pRoot->GetHandle() ) )
  23. {
  24. Msg( "CreateTargetFile_PCF: Error writing buffer\n" );
  25. return false;
  26. }
  27. g_pDataModel->RemoveFileId( pRoot->GetFileId() );
  28. WriteBufferToFile( pTargetName, binaryBuffer, bWriteToZip, g_WriteModeForConversions );
  29. return true;
  30. }