|
| void * | LoadWholeFile (const char *pszPath, void *pBuffer, unsigned nBufferSize, unsigned *pnSize) |
| | Read a whole file.
|
| void * | LoadGzFile (const char *pszPath, void *pBuffer, unsigned nBufferSize, unsigned *pnSize) |
| | Read a whole compressed file, decompressing it.
|
| int | OpenStreamByPath (const char *pszPath) |
| | Open a file, whether it resolves to 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.
|
| void | FilenameToISO9660 (const char *pszComponent, char *pszPath) |
| | Append a component to a device path.
|
| void | CloseLoadFile (int nFile) |
| | Close an open file, whether it is an ark stream or a loose file.
|
| int | FindOpenFileInArkTrueSize (int nStream) |
| | Report the decompressed size of the file an ark stream reads.
|
| unsigned | GetGzFileSize (int nFile) |
| | Report the decompressed size of a compressed loose file.
|
| void | GzipDecompressFdToRam (int nFile, void *pBuffer) |
| | Decompress a whole file into a buffer.
|
| int | GzipDecompressRamToRam (const void *pSource, int nSourceLength, void *pDest) |
| | Inflate a gzip member that is already in memory.
|
| int | FileSize (const char *pszPath) |
| | Report the stored length of a file.
|
| int | FileTrueSize (const char *pszPath) |
| | Report the uncompressed length of a file.
|
| int | GzipRefillInputBuffer (int nSilentEof) |
| | Refill the staging buffer from the memory source or the file and report its first byte.
|
| void | GzipFlushWindow () |
| | Checksum the filled part of gzipWindow, copy it to the output, and rewind the window.
|
| int | GzipGetByte () |
| | Read one byte through the staging buffer, refilling the buffer when it is exhausted.
|
| void * LoadWholeFile |
( |
const char * | pszPath, |
|
|
void * | pBuffer, |
|
|
unsigned | nBufferSize, |
|
|
unsigned * | pnSize ) |
Read a whole file.
A path whose last three characters match kGzExtension, tested without regard to case, is handed to LoadGzFile() instead. Any other path is opened, measured, and read in one call.
With no buffer supplied the routine allocates one, from the selected zone when there is one and from MemAllocTagged() otherwise. With a buffer supplied that is too small the file is closed and the load reports null.
- Parameters
-
| pszPath | The file to read. |
| pBuffer | The destination, or null to have one allocated. |
| nBufferSize | The destination size, which is ignored when pBuffer is null. |
| pnSize | Receives the file size, and is written even when the allocation failed. |
- Returns
- The destination, or null when the file could not be opened or read.
- Ghidra address:
- NTSC-U/C: 0x00555538
- Ghidra address:
- PAL: 0x00595bc0
| void * LoadGzFile |
( |
const char * | pszPath, |
|
|
void * | pBuffer, |
|
|
unsigned | nBufferSize, |
|
|
unsigned * | pnSize ) |
Read a whole compressed file, decompressing it.
The size queried and reported is the decompressed size, and the reader inflates the whole file in one call. Whether the query and the read address an ark stream or a loose file depends on UsingArkFiles().
A supplied buffer that is too small is fatal here rather than a null report, the one behavioural difference from LoadWholeFile(). The file is not closed on the success path.
- Parameters
-
| pszPath | The file to read. |
| pBuffer | The destination, or null to have one allocated. |
| nBufferSize | The destination size, which is ignored when pBuffer is null. |
| pnSize | Receives the decompressed size. |
- Returns
- The destination, or null when the file could not be opened.
- Ghidra address:
- NTSC-U/C: 0x00555678
- Ghidra address:
- PAL: 0x00595d00
| int FindOpenFileInArkTrueSize |
( |
int | nStream | ) |
|
Report the decompressed size of the file an ark stream reads.
The routine clears bit 0x4000 from the handle, finds the matching record in the stream table, and reports its directory entry's decompressed size. Nothing about it is specific to compression. LoadGzFile() simply needs that size, and the ark reader at 0x0055a280 uses the same entry's stored size to measure how much of the stream remains.
- Parameters
-
| nStream | The ark stream handle. |
- Returns
- The decompressed size in bytes, or -1 when no record has that handle.
- Ghidra address:
- NTSC-U/C: 0x0055bf88
- Ghidra address:
- PAL: 0x0059d1a8
| void GzipDecompressFdToRam |
( |
int | nFile, |
|
|
void * | pBuffer ) |
Decompress a whole file into a buffer.
Vendored gzip glue, declared by title only. The body stores the file in the bundled gzip code's input-descriptor global at 0x00761488, copies unknown into its input-name global at 0x00761490, and drives the gzip routines at 0x006125b8, 0x00612468, 0x00562f88, 0x0061d778, and 0x006125d0. Both exits close the file with close() unless the descriptor reads -1. The failure exit puts -1 in the result register. LoadGzFile(), the one caller, ignores the result.
- Parameters
-
| nFile | The file to read. |
| pBuffer | The destination, which must take the whole decompressed size. |
- Ghidra address:
- NTSC-U/C: 0x005635b8
- Ghidra address:
- PAL: 0x005a1d28
| int FileTrueSize |
( |
const char * | pszPath | ) |
|
Report the uncompressed length of a file.
It opens the path, measures it from the ark directory record, the gzip trailer, or the file size, and reports the length without reporting the handle. A caller that needs the file opens it again.
- Parameters
-
| pszPath | The file to measure. |
- Returns
- The uncompressed length, or zero or less when the file could not be opened.
- Ghidra address:
- NTSC-U/C: 0x00555800
- Ghidra address:
- PAL: 0x00595e88