W3DFileSystem.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. ** Command & Conquer Generals(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. virtual bool Is_Available(int forced=false);
  51. virtual bool Is_Open(void) const;
  52. virtual int Open(char const *filename, int rights=READ);
  53. virtual int Open(int rights=READ);
  54. virtual int Read(void *buffer, int len);
  55. virtual int Seek(int pos, int dir=SEEK_CUR);
  56. virtual int Size(void);
  57. virtual int Write(void const *buffer, int len);
  58. virtual void Close(void);
  59. protected:
  60. File *m_theFile; /// < The file
  61. Bool m_fileExists; ///< TRUE if the file exists
  62. char m_filePath[_MAX_PATH]; ///< the file name *and* path (relative)
  63. char m_filename[_MAX_PATH]; ///< The file name only
  64. };
  65. /*
  66. ** W3DFileSystem is a derived FileFactoryClass which
  67. ** uses GDI assets.
  68. */
  69. class W3DFileSystem : public FileFactoryClass {
  70. public:
  71. W3DFileSystem(void);
  72. ~W3DFileSystem(void);
  73. virtual FileClass * Get_File( char const *filename );
  74. virtual void Return_File( FileClass *file );
  75. };
  76. extern W3DFileSystem *TheW3DFileSystem;
  77. #endif