Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
rcfile.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 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : wwlib *
24 * *
25 * $Archive:: /Commando/Code/wwlib/rcfile.h $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 11/02/01 1:21p $*
30 * *
31 * $Revision:: 8 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#if defined(_MSC_VER)
38#pragma once
39#endif
40
41#ifndef RCFILE_H
42#define RCFILE_H
43
44#include "always.h"
45#include "wwfile.h"
46#include "win.h"
47
48/*
49** ResourceFileClass
50** This is a file class which allows you to read from a binary file that you have
51** imported into your resources. Just import the file as a custom resource of the
52** type "File". Replace the "id" of the resource with its filename (change
53** IDR_FILE1 to "MyFile.w3d") and then you will be able to access it by using this
54** class.
55*/
57{
58 public:
59
60 ResourceFileClass(HMODULE hmodule, char const *filename);
61 virtual ~ResourceFileClass(void);
62
63 virtual char const * File_Name(void) const { return ResourceName; }
64 virtual char const * Set_Name(char const *filename);
65 virtual int Create(void) { return false; }
66 virtual int Delete(void) { return false; }
67 virtual bool Is_Available(int /*forced=false*/) { return Is_Open (); }
68 virtual bool Is_Open(void) const { return (FileBytes != NULL); }
69
70 virtual int Open(char const * /*fname*/, int /*rights=READ*/) { return Is_Open(); }
71 virtual int Open(int /*rights=READ*/) { return Is_Open(); }
72
73 virtual int Read(void *buffer, int size);
74 virtual int Seek(int pos, int dir=SEEK_CUR);
75 virtual int Size(void);
76 virtual int Write(void const * /*buffer*/, int /*size*/) { return 0; }
77 virtual void Close(void) { }
78 virtual void Error(int error, int canretry = false, char const * filename=NULL);
79 virtual void Bias(int start, int length=-1) {}
80
81 virtual unsigned char *Peek_Data(void) const { return FileBytes; }
82
83 protected:
84
86
87 HMODULE hModule;
88
89 unsigned char * FileBytes;
90 unsigned char * FilePtr;
91 unsigned char * EndOfFile;
92
93};
94
95
96#endif
#define NULL
Definition BaseType.h:92
#define SEEK_CUR
Definition WWFILE.H:56
char dir[_MAX_DIR]
Definition autorun.cpp:215
virtual unsigned char * Peek_Data(void) const
Definition rcfile.h:81
virtual int Size(void)
Definition rcfile.cpp:122
virtual int Write(void const *, int)
Definition rcfile.h:76
virtual char const * Set_Name(char const *filename)
Definition rcfile.cpp:72
HMODULE hModule
Definition rcfile.h:87
virtual void Bias(int start, int length=-1)
Definition rcfile.h:79
virtual char const * File_Name(void) const
Definition rcfile.h:63
ResourceFileClass(HMODULE hmodule, char const *filename)
Definition rcfile.cpp:44
virtual int Delete(void)
Definition rcfile.h:66
unsigned char * FileBytes
Definition rcfile.h:89
virtual void Close(void)
Definition rcfile.h:77
virtual int Open(char const *, int)
Definition rcfile.h:70
unsigned char * FilePtr
Definition rcfile.h:90
unsigned char * EndOfFile
Definition rcfile.h:91
virtual int Read(void *buffer, int size)
Definition rcfile.cpp:84
virtual int Open(int)
Definition rcfile.h:71
char * ResourceName
Definition rcfile.h:85
virtual bool Is_Open(void) const
Definition rcfile.h:68
virtual ~ResourceFileClass(void)
Definition rcfile.cpp:66
virtual int Seek(int pos, int dir=SEEK_CUR)
Definition rcfile.cpp:96
virtual int Create(void)
Definition rcfile.h:65
virtual void Error(int error, int canretry=false, char const *filename=NULL)
Definition rcfile.cpp:127
virtual bool Is_Available(int)
Definition rcfile.h:67