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.

61 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implementation of CEventList
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include <stdlib.h>
  14. #include "TFStatsApplication.h"
  15. #include "EventList.h"
  16. #include "memdbg.h"
  17. #pragma warning (disable : 4786)
  18. //------------------------------------------------------------------------------------------------------
  19. // Function: CEventList::readEventList
  20. // Purpose: reads and returns a CEventList from a logfile
  21. // Input: filename - the logfile to read from
  22. // Output: CEventList*
  23. //------------------------------------------------------------------------------------------------------
  24. CEventList* CEventList::readEventList(const char* filename)
  25. {
  26. // ifstream ifs(filename);
  27. CEventList* plogfile=new TRACKED CEventList();
  28. if (!plogfile)
  29. {
  30. printf("TFStats ran out of memory!\n");
  31. return NULL;
  32. }
  33. FILE* f=fopen(filename,"rt");
  34. if (!f)
  35. g_pApp->fatalError("Error opening %s, please make sure that the file exists and is not being accessed by other processes",filename);
  36. while (!feof(f))
  37. {
  38. CLogEvent* curr=NULL;
  39. curr=new TRACKED CLogEvent(f);
  40. if (!curr->isValid())
  41. {
  42. delete curr;
  43. break;//eof reached
  44. }
  45. plogfile->insert(plogfile->end(),curr);
  46. }
  47. fclose(f);
  48. #ifndef WIN32
  49. chmod(filename,PERMIT);
  50. #endif
  51. return plogfile;
  52. }