| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** Confidential - Westwood Studios ***
- ***********************************************************************************************
- * *
- * Project Name : Commando *
- * *
- * $Archive:: /Commando/Code/wwlib/mixfile.h $*
- * *
- * $Author:: Steve_t $*
- * *
- * $Modtime:: 9/07/01 5:29p $*
- * *
- * $Revision:: 4 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #ifndef MIXFILE_H
- #define MIXFILE_H
- #ifndef ALWAYS_H
- #include "always.h"
- #endif
- #ifndef FFACTORY_H
- #include "ffactory.h"
- #endif
- #ifndef WWSTRING_H
- #include "wwstring.h"
- #endif
- #include "vector.h"
- class FileClass;
- /*
- **
- */
- class MixFileFactoryClass : public FileFactoryClass {
- public:
- MixFileFactoryClass( const char * mix_filename, FileFactoryClass * factory );
- virtual ~MixFileFactoryClass( void );
- //
- // Inherited
- //
- virtual FileClass * Get_File( char const *filename );
- virtual void Return_File( FileClass *file );
- //
- // Filename access
- //
- bool Build_Filename_List (DynamicVectorClass<StringClass> &list);
- bool Build_Ordered_Filename_List (DynamicVectorClass<StringClass> &list); // ordered by offset in mixfile
- bool Build_Internal_Filename_List (void) { return Build_Filename_List (FilenameList); }
- void Get_Filename_List (DynamicVectorClass<StringClass> **list) { *list = &FilenameList; }
- void Get_Filename_List (DynamicVectorClass<StringClass> &list) { list = FilenameList; }
- //
- // Content control
- //
- void Add_File (const char *full_path, const char *filename);
- void Delete_File (const char *filename);
- void Flush_Changes (void);
- //
- // Information
- //
- bool Is_Valid (void) const { return IsValid; }
- private:
- //
- // Utility functions
- //
- bool Get_Temp_Filename (const char *path, StringClass &full_path);
- static int File_Offset_Compare(const void * a, const void * b);
- struct FileInfoStruct {
- bool operator== (const FileInfoStruct &src) { return false; }
- bool operator!= (const FileInfoStruct &src) { return true; }
- unsigned long CRC; // CRC code for embedded file.
- unsigned long Offset; // Offset from start of data section.
- unsigned long Size; // Size of data subfile.
- };
- struct AddInfoStruct {
- bool operator== (const AddInfoStruct &src) { return false; }
- bool operator!= (const AddInfoStruct &src) { return true; }
- StringClass FullPath;
- StringClass Filename;
- };
- FileFactoryClass * Factory;
- DynamicVectorClass<FileInfoStruct> FileInfo;
- StringClass MixFilename;
- int BaseOffset;
- int FileCount;
- int NamesOffset;
- bool IsValid;
- DynamicVectorClass<StringClass> FilenameList;
- DynamicVectorClass<AddInfoStruct> PendingAddFileList;
- bool IsModified;
- };
- /*
- **
- */
- class MixFileCreator {
- public:
- MixFileCreator( const char * filename );
- ~MixFileCreator( void );
- void Add_File( const char * source_filename, const char * saved_filename = NULL );
- void Add_File( const char * filename, FileClass *file );
- private:
- static int File_Info_Compare(const void * a, const void * b);
- struct FileInfoStruct {
- bool operator== (const FileInfoStruct &src) { return false; }
- bool operator!= (const FileInfoStruct &src) { return true; }
- unsigned long CRC; // CRC code for embedded file.
- unsigned long Offset; // Offset from start of data section.
- unsigned long Size; // Size of data subfile.
- StringClass Filename;
- };
- DynamicVectorClass<FileInfoStruct> FileInfo;
- FileClass * MixFile;
- };
- /*
- **
- */
- void Setup_Mix_File( void );
- #endif
|