CCFILE.H 4.7 KB

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