CCFILE.H 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/CCFILE.H 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : CCFILE.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : October 17, 1994 *
  26. * *
  27. * Last Update : October 17, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef CCFILE_H
  33. #define CCFILE_H
  34. //#include <wwlib32.h>
  35. #include <limits.h>
  36. #include "mixfile.h"
  37. #include "cdfile.h"
  38. #include "buff.h"
  39. /*
  40. ** This derived class for file access knows about mixfiles (packed files). It can handle opening
  41. ** a file that is embedded within a mixfile. This is true if the mixfile is cached or resides on
  42. ** disk. It is functionally similar to pakfiles, except much faster and less RAM intensive.
  43. */
  44. class CCFileClass : public CDFileClass
  45. {
  46. public:
  47. CCFileClass(char const * filename);
  48. CCFileClass(void);
  49. virtual ~CCFileClass(void) {Position = 0;};
  50. // Delete should be overloaded here as well. Don't allow deletes of mixfiles.
  51. bool Is_Resident(void) const {return(Data.Get_Buffer() != NULL);}
  52. virtual int Is_Available(int forced=false);
  53. virtual int Is_Open(void) const;
  54. virtual int Open(char const * filename, int rights=READ) {Set_Name(filename);return Open(rights);};
  55. virtual int Open(int rights=READ);
  56. virtual long Read(void * buffer, long size);
  57. virtual long Seek(long pos, int dir=SEEK_CUR);
  58. virtual long Size(void);
  59. virtual long Write(void const * buffer, long size);
  60. virtual void Close(void);
  61. virtual unsigned long Get_Date_Time(void);
  62. virtual bool Set_Date_Time(unsigned long datetime);
  63. virtual void Error(int error, int canretry = false, char const * filename=NULL);
  64. private:
  65. /*
  66. ** This indicates the file is actually part of a resident image of the mixfile
  67. ** itself. In this case, the embedded file handle is invalid. All file access actually
  68. ** gets routed through the cached version of the file. This is a pointer to the start
  69. ** of the RAM image of the file.
  70. */
  71. ::Buffer Data;
  72. // void * Pointer;
  73. /*
  74. ** This is the size of the file if it was embedded in a mixfile. The size must be manually
  75. ** kept track of because the DOS file size is invalid.
  76. */
  77. // long Length;
  78. /*
  79. ** This is the current seek position of the file. It is duplicated here if the file is
  80. ** part of a mixfile since the DOS seek position is not accurate. This value will
  81. ** range from zero to the size of the file in bytes.
  82. */
  83. long Position;
  84. // Force these to never be invoked.
  85. CCFileClass const & operator = (CCFileClass const & c);
  86. CCFileClass (CCFileClass const & );
  87. };
  88. template <> class MixFileClass<CDFileClass>;
  89. #endif