ArchiveFile.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /////// ArchiveFile.h ////////////////////
  24. // Bryan Cleveland, August 2002
  25. //////////////////////////////////////////
  26. #pragma once
  27. #ifndef __ARCHIVEFILE_H
  28. #define __ARCHIVEFILE_H
  29. #include "Lib/BaseType.h"
  30. #include "Common/AsciiString.h"
  31. #include "Common/ArchiveFileSystem.h"
  32. class File;
  33. /**
  34. * An archive file is itself a collection of sub files. Each file inside the archive file
  35. * has a unique name by which it can be accessed. The ArchiveFile object class is the
  36. * runtime interface to the mix file and the sub files. Each file inside the mix
  37. * file can be accessed by the openFile().
  38. *
  39. * ArchiveFile interfaces can be created by the TheArchiveFileSystem object.
  40. */
  41. //===============================
  42. class ArchiveFile
  43. {
  44. public:
  45. ArchiveFile();
  46. virtual ~ArchiveFile();
  47. virtual Bool getFileInfo( const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested.
  48. virtual File* openFile( const Char *filename, Int access = 0) = 0; ///< Open the specified file within the archive file
  49. virtual void closeAllFiles( void ) = 0; ///< Close all file opened in this archive file
  50. virtual AsciiString getName( void ) = 0; ///< Returns the name of the archive file
  51. virtual AsciiString getPath( void ) = 0; ///< Returns full path and name of archive file
  52. virtual void setSearchPriority( Int new_priority ) = 0; ///< Set this archive file's search priority
  53. virtual void close( void ) = 0; ///< Close this archive file
  54. void attachFile(File *file);
  55. void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const;
  56. void getFileListInDirectory(const DetailedArchivedDirectoryInfo *dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const;
  57. void addFile(const AsciiString& path, const ArchivedFileInfo *fileInfo); ///< add this file to our directory tree.
  58. protected:
  59. const ArchivedFileInfo * getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree.
  60. File *m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time.
  61. DetailedArchivedDirectoryInfo m_rootDirectory;
  62. };
  63. #endif // __ARCHIVEFILE_H