Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
mixfile.h
Go to the documentation of this file.
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 *** Confidential - Westwood Studios ***
21 ***********************************************************************************************
22 * *
23 * Project Name : Commando *
24 * *
25 * $Archive:: /Commando/Code/wwlib/mixfile.h $*
26 * *
27 * $Author:: Steve_t $*
28 * *
29 * $Modtime:: 9/07/01 5:29p $*
30 * *
31 * $Revision:: 4 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#ifndef MIXFILE_H
38#define MIXFILE_H
39
40#ifndef ALWAYS_H
41 #include "always.h"
42#endif
43
44#ifndef FFACTORY_H
45 #include "ffactory.h"
46#endif
47
48#ifndef WWSTRING_H
49 #include "wwstring.h"
50#endif
51
52#include "vector.h"
53
54class FileClass;
55
56/*
57**
58*/
60
61public:
62 MixFileFactoryClass( const char * mix_filename, FileFactoryClass * factory );
63 virtual ~MixFileFactoryClass( void );
64
65 //
66 // Inherited
67 //
68 virtual FileClass * Get_File( char const *filename );
69 virtual void Return_File( FileClass *file );
70
71 //
72 // Filename access
73 //
75 bool Build_Ordered_Filename_List (DynamicVectorClass<StringClass> &list); // ordered by offset in mixfile
76 bool Build_Internal_Filename_List (void) { return Build_Filename_List (FilenameList); }
77 void Get_Filename_List (DynamicVectorClass<StringClass> **list) { *list = &FilenameList; }
78 void Get_Filename_List (DynamicVectorClass<StringClass> &list) { list = FilenameList; }
79
80 //
81 // Content control
82 //
83 void Add_File (const char *full_path, const char *filename);
84 void Delete_File (const char *filename);
85 void Flush_Changes (void);
86
87 //
88 // Information
89 //
90 bool Is_Valid (void) const { return IsValid; }
91
92private:
93
94 //
95 // Utility functions
96 //
97 bool Get_Temp_Filename (const char *path, StringClass &full_path);
98 static int File_Offset_Compare(const void * a, const void * b);
99
100 struct FileInfoStruct {
101 bool operator== (const FileInfoStruct &src) { return false; }
102 bool operator!= (const FileInfoStruct &src) { return true; }
103
104 unsigned long CRC; // CRC code for embedded file.
105 unsigned long Offset; // Offset from start of data section.
106 unsigned long Size; // Size of data subfile.
107 };
108
109 struct AddInfoStruct {
110 bool operator== (const AddInfoStruct &src) { return false; }
111 bool operator!= (const AddInfoStruct &src) { return true; }
112
113 StringClass FullPath;
114 StringClass Filename;
115 };
116
117 FileFactoryClass * Factory;
118 DynamicVectorClass<FileInfoStruct> FileInfo;
119 StringClass MixFilename;
120 int BaseOffset;
121
122 int FileCount;
123 int NamesOffset;
124 bool IsValid;
125 DynamicVectorClass<StringClass> FilenameList;
126
127 DynamicVectorClass<AddInfoStruct> PendingAddFileList;
128 bool IsModified;
129};
130
131/*
132**
133*/
135
136public:
137 MixFileCreator( const char * filename );
138 ~MixFileCreator( void );
139
140 void Add_File( const char * source_filename, const char * saved_filename = NULL );
141 void Add_File( const char * filename, FileClass *file );
142
143private:
144
145 static int File_Info_Compare(const void * a, const void * b);
146
147 struct FileInfoStruct {
148 bool operator== (const FileInfoStruct &src) { return false; }
149 bool operator!= (const FileInfoStruct &src) { return true; }
150
151 unsigned long CRC; // CRC code for embedded file.
152 unsigned long Offset; // Offset from start of data section.
153 unsigned long Size; // Size of data subfile.
154 StringClass Filename;
155 };
156
158 FileClass * MixFile;
159};
160
161/*
162**
163*/
164void Setup_Mix_File( void );
165
166#endif
#define NULL
Definition BaseType.h:92
Definition crc.h:59
MixFileCreator(const char *filename)
Definition mixfile.cpp:469
~MixFileCreator(void)
Definition mixfile.cpp:496
void Add_File(const char *source_filename, const char *saved_filename=NULL)
Definition mixfile.cpp:558
void Delete_File(const char *filename)
Definition mixfile.cpp:288
virtual void Return_File(FileClass *file)
Definition mixfile.cpp:261
void Flush_Changes(void)
Definition mixfile.cpp:309
void Get_Filename_List(DynamicVectorClass< StringClass > **list)
Definition mixfile.h:77
virtual FileClass * Get_File(char const *filename)
Definition mixfile.cpp:216
bool Build_Ordered_Filename_List(DynamicVectorClass< StringClass > &list)
Definition mixfile.cpp:426
void Get_Filename_List(DynamicVectorClass< StringClass > &list)
Definition mixfile.h:78
void Add_File(const char *full_path, const char *filename)
Definition mixfile.cpp:273
bool Build_Filename_List(DynamicVectorClass< StringClass > &list)
Definition mixfile.cpp:152
bool Is_Valid(void) const
Definition mixfile.h:90
virtual ~MixFileFactoryClass(void)
Definition mixfile.cpp:147
MixFileFactoryClass(const char *mix_filename, FileFactoryClass *factory)
Definition mixfile.cpp:74
bool Build_Internal_Filename_List(void)
Definition mixfile.h:76
void Setup_Mix_File(void)
Definition mixfile.cpp:685