resonance 1.0.1
Loading...
Searching...
No Matches
loadfile.h
Go to the documentation of this file.
1#pragma once
2
4constexpr char kGzExtension[] = ".gz";
5
24void *LoadWholeFile(const char *pszPath, void *pBuffer, unsigned nBufferSize, unsigned *pnSize);
25
44void *LoadGzFile(const char *pszPath, void *pBuffer, unsigned nBufferSize, unsigned *pnSize);
45
56int OpenStreamByPath(const char *pszPath);
57
72void ReadStreamChunk(int nFile, int nSector, void *pBuffer, unsigned nLength);
73
85void FilenameToISO9660(const char *pszComponent, char *pszPath);
86
96void CloseLoadFile(int nFile);
97
112
121unsigned GetGzFileSize(int nFile);
122
138extern "C" void GzipDecompressFdToRam(int nFile, void *pBuffer);
139
154int GzipDecompressRamToRam(const void *pSource, int nSourceLength, void *pDest);
155
167int FileSize(const char *pszPath);
168
180int FileTrueSize(const char *pszPath);
181
183constexpr unsigned kGzipWindowSize = 0x8000;
184
185extern "C" {
186
195extern unsigned char gzipWindow[2 * kGzipWindowSize];
196
203extern unsigned gzipOutcnt;
204
211extern unsigned char gzipInbuf[];
212
219extern unsigned gzipInsize;
220
227extern unsigned gzipInptr;
228
237int GzipRefillInputBuffer(int nSilentEof);
238
248
249} // extern "C"
250
256inline int GzipGetByte() {
257 if (gzipInptr < gzipInsize) {
258 return gzipInbuf[gzipInptr++];
259 }
260 return GzipRefillInputBuffer(0);
261}
int GzipRefillInputBuffer(int nSilentEof)
Refill the staging buffer from the memory source or the file and report its first byte.
unsigned gzipOutcnt
The write position in gzipWindow.
void CloseLoadFile(int nFile)
Close an open file, whether it is an ark stream or a loose file.
void ReadStreamChunk(int nFile, int nSector, void *pBuffer, unsigned nLength)
Read one chunk of a file into a buffer.
int FileSize(const char *pszPath)
Report the stored length of a file.
int GzipGetByte()
Read one byte through the staging buffer, refilling the buffer when it is exhausted.
Definition loadfile.h:256
void FilenameToISO9660(const char *pszComponent, char *pszPath)
Append a component to a device path.
constexpr char kGzExtension[]
Extension that routes a load through the decompressing path.
Definition loadfile.h:4
unsigned GetGzFileSize(int nFile)
Report the decompressed size of a compressed loose file.
unsigned gzipInsize
The valid byte count in gzipInbuf.
void * LoadGzFile(const char *pszPath, void *pBuffer, unsigned nBufferSize, unsigned *pnSize)
Read a whole compressed file, decompressing it.
void * LoadWholeFile(const char *pszPath, void *pBuffer, unsigned nBufferSize, unsigned *pnSize)
Read a whole file.
int FindOpenFileInArkTrueSize(int nStream)
Report the decompressed size of the file an ark stream reads.
int GzipDecompressRamToRam(const void *pSource, int nSourceLength, void *pDest)
Inflate a gzip member that is already in memory.
unsigned gzipInptr
The read position in gzipInbuf.
int OpenStreamByPath(const char *pszPath)
Open a file, whether it resolves to an ark stream or a loose file.
unsigned char gzipInbuf[]
The staging buffer refilled from the memory source or the file.
unsigned char gzipWindow[2 *kGzipWindowSize]
The decompressor window.
void GzipFlushWindow()
Checksum the filled part of gzipWindow, copy it to the output, and rewind the window.
constexpr unsigned kGzipWindowSize
The window length the decompressor fills before each flush.
Definition loadfile.h:183
void GzipDecompressFdToRam(int nFile, void *pBuffer)
Decompress a whole file into a buffer.
int FileTrueSize(const char *pszPath)
Report the uncompressed length of a file.