coastline 0.0.4
Loading...
Searching...
No Matches
podarchive.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <cstdint>
9#include <cstdio>
10
12#define POD_ENTRY_NAME_SIZE 64
14#define POD_PATH_SIZE 0x400
16#define POD_WRITER_ENTRY_COUNT 4096
18#define POD_FILE_VERSION 500
19
27
29struct PodEntry {
30 int32_t dwOffset;
31 unsigned dwSize;
32 unsigned char bAttrA;
33 unsigned char bAttrB;
34 char abUnknownA[2];
36};
37
40public:
48
57 void ExtractFileName(const char *pszPath, char *pszName);
58
67 FILE *FileOpenBinaryWriteOrFatal(const char *pszPath);
68
77 FILE *FileOpenBinaryReadOrFatal(const char *pszPath);
78
88 void FileReadExactOrFatal(FILE *pFile, void *pBuffer, unsigned dwSize);
89
99 void FileWriteChecked(FILE *pFile, const void *pBuffer, unsigned dwSize);
100};
101
102#ifdef __cplusplus
103extern "C" {
104#endif
105
113void FatalErrorWithMessage(const char *pszFormat, ...);
114#ifdef __cplusplus
115}
116#endif
117
120private:
121 void ClearPodArchive();
122
123 PodFileHelper helper;
124 PodHeader header;
125 PodEntry *pEntries;
126 FILE *pFile;
127 char szPath[POD_PATH_SIZE];
128 unsigned dwDirectorySize;
129
130public:
137 virtual ~PodArchive();
138
139private:
149 virtual void CleanupName(const char *pszPath, char *pszName);
150
159 virtual int FindPodIndexByName(const char *pszPath);
160
169 virtual int GetPodIndexByName(const char *pszPath);
170
179 virtual unsigned GetPodLength(unsigned nIndex);
180
189 virtual void ReadPodBytesFromFile(unsigned nIndex, void *pBuffer);
190
191public:
201 virtual void *LoadPodByName(const char *pszPath, void *pBuffer);
202
203private:
213 virtual void *LoadPodEntryByIndex(unsigned nIndex, void *pBuffer);
214
223 virtual void *AllocAndLoadPodByName(const char *pszPath);
224
233 virtual void *AllocAndLoadPodByIndex(unsigned nIndex);
234
235public:
243 virtual void OpenPodFile();
244
245private:
254 virtual void CreatePodFile(const char *pszPath);
255
267 virtual void
268 AddPodEntry(const char *pszPath, const void *pData, unsigned dwSize, char bAttrA, char bAttrB);
269
276 virtual void FinalizePodFile();
277
278public:
285 virtual void ClosePodFile();
286
294
302 void SetFilePath(const char *pszPath);
303};
304
312
313#if TGR_PLATFORM == TGR_PLATFORM_SDL
322bool ReadImportedPodEntry(const char *pszPath, void *pBuffer);
323#endif /* TGR_PLATFORM == TGR_PLATFORM_SDL */
A pod file the game reads, and the writer of one.
Definition podarchive.h:119
virtual void * LoadPodByName(const char *pszPath, void *pBuffer)
Read the data of the entry of a path.
virtual void ClosePodFile()
Close the file, free the directory, and clear the archive and its path.
PodArchive()
An archive without a file.
virtual void OpenPodFile()
Open the pod file of the path to read, and read its header and directory.
void SetFilePath(const char *pszPath)
Set the path of the file of the archive.
virtual ~PodArchive()
Do nothing.
The files a pod archive reads and writes.
Definition podarchive.h:39
FILE * FileOpenBinaryWriteOrFatal(const char *pszPath)
Create a file to write.
FILE * FileOpenBinaryReadOrFatal(const char *pszPath)
Open a file to read.
void ExtractFileName(const char *pszPath, char *pszName)
Copy the part of a path after its last backslash.
PodFileHelper()
Initialise the archive helper without opening a file.
void FileReadExactOrFatal(FILE *pFile, void *pBuffer, unsigned dwSize)
Read an exact number of bytes from a file.
void FileWriteChecked(FILE *pFile, const void *pBuffer, unsigned dwSize)
Write an exact number of bytes to a file.
bool ReadImportedPodEntry(const char *pszPath, void *pBuffer)
Read an entry of BossRally.pod from its import, the directory BossRally of the default assets,...
#define POD_ENTRY_NAME_SIZE
The size of the name of an entry of a pod file.
Definition podarchive.h:12
void FatalErrorWithMessage(const char *pszFormat,...)
Format a message of an error that is not shown, and end the game.
#define POD_PATH_SIZE
The size of the path of a pod file.
Definition podarchive.h:14
PodArchive g_BossRallyPodArchive
The archive of the data of the game.
An entry of the directory of a pod file.
Definition podarchive.h:29
unsigned dwSize
Definition podarchive.h:31
unsigned char bAttrA
Definition podarchive.h:32
int32_t dwOffset
Definition podarchive.h:30
char szName[POD_ENTRY_NAME_SIZE]
Definition podarchive.h:35
unsigned char bAttrB
Definition podarchive.h:33
char abUnknownA[2]
Definition podarchive.h:34
The header at the start of a pod file.
Definition podarchive.h:21
int nEntryCount
Definition podarchive.h:24
int32_t dwDirectoryOffset
Definition podarchive.h:25
int nVersion
Definition podarchive.h:23
char szSignature[4]
Definition podarchive.h:22