rcfile.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. ** Command & Conquer Renegade(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. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : wwlib *
  23. * *
  24. * $Archive:: /Commando/Code/wwlib/rcfile.h $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 11/02/01 1:21p $*
  29. * *
  30. * $Revision:: 8 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef RCFILE_H
  39. #define RCFILE_H
  40. #include "always.h"
  41. #include "wwfile.h"
  42. #include "win.h"
  43. /*
  44. ** ResourceFileClass
  45. ** This is a file class which allows you to read from a binary file that you have
  46. ** imported into your resources. Just import the file as a custom resource of the
  47. ** type "File". Replace the "id" of the resource with its filename (change
  48. ** IDR_FILE1 to "MyFile.w3d") and then you will be able to access it by using this
  49. ** class.
  50. */
  51. class ResourceFileClass : public FileClass
  52. {
  53. public:
  54. ResourceFileClass(HMODULE hmodule, char const *filename);
  55. virtual ~ResourceFileClass(void);
  56. virtual char const * File_Name(void) const { return ResourceName; }
  57. virtual char const * Set_Name(char const *filename);
  58. virtual int Create(void) { return false; }
  59. virtual int Delete(void) { return false; }
  60. virtual bool Is_Available(int /*forced=false*/) { return Is_Open (); }
  61. virtual bool Is_Open(void) const { return (FileBytes != NULL); }
  62. virtual int Open(char const * /*fname*/, int /*rights=READ*/) { return Is_Open(); }
  63. virtual int Open(int /*rights=READ*/) { return Is_Open(); }
  64. virtual int Read(void *buffer, int size);
  65. virtual int Seek(int pos, int dir=SEEK_CUR);
  66. virtual int Size(void);
  67. virtual int Write(void const * /*buffer*/, int /*size*/) { return 0; }
  68. virtual void Close(void) { }
  69. virtual void Error(int error, int canretry = false, char const * filename=NULL);
  70. virtual void Bias(int start, int length=-1) {}
  71. virtual unsigned char *Peek_Data(void) const { return FileBytes; }
  72. protected:
  73. char * ResourceName;
  74. HMODULE hModule;
  75. unsigned char * FileBytes;
  76. unsigned char * FilePtr;
  77. unsigned char * EndOfFile;
  78. };
  79. #endif