W3DFileSystem.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: W3DFileSystem.h ////////////////////////////////////////////////////////
  24. //
  25. // W3D implementation of a file factory. Uses GDI assets, so that
  26. // W3D files and targa files are loaded using the GDI file interface.
  27. //
  28. // Author: John Ahlquist, Sept 2001
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////
  31. #if _MSC_VER >= 1000
  32. #pragma once
  33. #endif // _MSC_VER >= 1000
  34. #ifndef __W3DFILESYSTEM_H_
  35. #define __W3DFILESYSTEM_H_
  36. #include "WWLIB/ffactory.h"
  37. #include "Common/File.h"
  38. //-------------------------------------------------------------------------------------------------
  39. /** Game file access. At present this allows us to access test assets, assets from
  40. * legacy GDI assets, and the current flat directory access for textures, models etc */
  41. //-------------------------------------------------------------------------------------------------
  42. class GameFileClass : public FileClass
  43. {
  44. public:
  45. GameFileClass(char const *filename);
  46. GameFileClass(void);
  47. virtual ~GameFileClass(void);
  48. virtual char const * File_Name(void) const;
  49. virtual char const * Set_Name(char const *filename);
  50. // (gth) had to re-instate these functions in the base class, for now just give empty implementations...
  51. virtual int Create(void) { assert(0); return 1; }
  52. virtual int Delete(void) { assert(0); return 1; }
  53. virtual bool Is_Available(int forced=false);
  54. virtual bool Is_Open(void) const;
  55. virtual int Open(char const *filename, int rights=READ);
  56. virtual int Open(int rights=READ);
  57. virtual int Read(void *buffer, int len);
  58. virtual int Seek(int pos, int dir=SEEK_CUR);
  59. virtual int Size(void);
  60. virtual int Write(void const *buffer, int len);
  61. virtual void Close(void);
  62. protected:
  63. File *m_theFile; /// < The file
  64. Bool m_fileExists; ///< TRUE if the file exists
  65. char m_filePath[_MAX_PATH]; ///< the file name *and* path (relative)
  66. char m_filename[_MAX_PATH]; ///< The file name only
  67. };
  68. /*
  69. ** W3DFileSystem is a derived FileFactoryClass which
  70. ** uses GDI assets.
  71. */
  72. class W3DFileSystem : public FileFactoryClass {
  73. public:
  74. W3DFileSystem(void);
  75. ~W3DFileSystem(void);
  76. virtual FileClass * Get_File( char const *filename );
  77. virtual void Return_File( FileClass *file );
  78. };
  79. extern W3DFileSystem *TheW3DFileSystem;
  80. #endif