CCFILE.H 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. ** Command & Conquer(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: F:\projects\c&c\vcs\code\ccfile.h_v 2.18 16 Oct 1995 16:45:28 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. /*
  43. ** This derived class for file access knows about mixfiles (packed files). It can handle opening
  44. ** a file that is embedded within a mixfile. This is true if the mixfile is cached or resides on
  45. ** disk. It is functionally similar to pakfiles, except much faster and less RAM intensive.
  46. */
  47. class CCFileClass : public CDFileClass
  48. {
  49. public:
  50. CCFileClass(char const *filename);
  51. CCFileClass(void);
  52. virtual ~CCFileClass(void) {};
  53. // Delete should be overloaded here as well. Don't allow deletes of mixfiles.
  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 int Is_Open(void) const;
  57. virtual int Is_Available(int forced=false);
  58. virtual long Read(void *buffer, long size);
  59. virtual long Seek(long pos, int dir=SEEK_CUR);
  60. virtual long Size(void);
  61. virtual long Write(void const *buffer, long size);
  62. virtual void Close(void);
  63. virtual void Error(int error, int canretry = false, char const * filename=NULL);
  64. private:
  65. /*
  66. ** This flag indicates that the file is part of a mixfile and the mixfile resides on
  67. ** disk. The file handle for this file is a legitimate DOS handle, although special
  68. ** handling is necessary that takes into account the embedded nature of the file.
  69. */
  70. bool FromDisk;
  71. /*
  72. ** This indicates the file is actually part of a resident image of the mixfile
  73. ** itself. In this case, the embedded file handle is invalid. All file access actually
  74. ** gets routed through the cached version of the file. This is a pointer to the start
  75. ** of the RAM image of the file.
  76. */
  77. void * Pointer;
  78. /*
  79. ** This is the starting offset of the beginning of the file. This value is only valid
  80. ** if the file is part of a mixfile that resides on disk. It serves as the counterpart
  81. ** to the "Pointer" variable.
  82. */
  83. long Start;
  84. /*
  85. ** This is the current seek position of the file. It is duplicated here if the file is
  86. ** part of a mixfile since the DOS seek position is not accurate. This value will
  87. ** range from zero to the size of the file in bytes.
  88. */
  89. long Position;
  90. /*
  91. ** This is the size of the file if it was embedded in a mixfile. The size must be manually
  92. ** kept track of because the DOS file size is invalid.
  93. */
  94. long Length;
  95. // Force these to never be invoked.
  96. CCFileClass const operator = (CCFileClass const & c);
  97. CCFileClass (CCFileClass const & ) {};
  98. };
  99. #endif