Iso9660Builder class
#include <Utilities/AssetPacker/Iso9660.h>
Generates an ISO 9660 file system.
Writes the plain hierarchy and a Joliet one beside it. Both are needed: the plain one is what the bootstrap of the Dreamcast looks 1ST_READ.BIN up in, and it can only spell names in upper case out of a very small alphabet, which mangles most of the names the game's content uses; the Joliet hierarchy carries them as they really are, and that is the one KallistiOS reads whenever a disc has it.
Files are placed at the end of the volume, where a CD passes the most data per rotation under the head. A disc that is mostly empty therefore reads its content roughly twice as fast as one filled from the inside out, which is what mkdcdisc does by default and what this preserves.
Public types
- using LeaveOutFunc = bool(*)(StringView name, bool isDirectory, bool isTopLevel)
- Decides whether an entry of a directory added from the file system is left out.
Constructors, destructors, conversion operators
Public functions
-
void SetSystemArea(ArrayView<const std::
uint8_t> data) - Sets the 32 KB system area the volume begins with.
-
void SetDescriptorTemplates(ArrayView<const std::
uint8_t> primary, ArrayView<const std:: uint8_t> supplementary) - Sets the volume descriptors the generated ones are derived from.
-
void SetTrackStartLba(std::
uint32_t lba) - Sets the absolute address the track carrying the volume begins at.
-
auto AddDirectory(StringView path,
const std::
uint8_t recorded[7]) -> bool - Adds an empty directory, which files added afterwards may be put in.
-
auto AddFileFromImage(StringView path,
std::
uint32_t lba, std:: uint32_t size, const std:: uint8_t recorded[7]) -> bool - Adds a file whose contents are copied from the volume being read.
- auto AddDirectoryFromDisk(StringView path, StringView hostPath, LeaveOutFunc leaveOut = nullptr) -> bool
- Adds a directory and everything below it from the file system.
- auto AddFileFromDisk(StringView path, StringView hostPath) -> bool
- Adds a single file from the file system.
-
auto GetRequiredSectorCount() -> std::
uint32_t - Number of logical sectors the volume needs to hold everything that was added.
-
auto FindFileLba(StringView path,
std::
uint32_t volumeSectorCount) -> std:: uint32_t - Absolute address the contents of a file are going to be written at.
-
auto Write(ISectorSink& sink,
std::
uint32_t volumeSectorCount, ISectorReader& imageReader) -> bool - Lays the volume out over the specified number of sectors and writes it.
Typedef documentation
using Jazz2:: AssetPacker:: Iso9660Builder:: LeaveOutFunc = bool(*)(StringView name, bool isDirectory, bool isTopLevel)
Decides whether an entry of a directory added from the file system is left out.
Called with the name of the entry, whether it's a directory and whether it's right in the directory that was added, not deeper. A directory left out is left out with everything in it.
Function documentation
void Jazz2:: AssetPacker:: Iso9660Builder:: SetDescriptorTemplates(ArrayView<const std:: uint8_t> primary,
ArrayView<const std:: uint8_t> supplementary)
Sets the volume descriptors the generated ones are derived from.
Everything that is not a size or an address — the volume label, the publisher, the dates — is taken from these, so a rewritten disc keeps the identity of the one it was made from. The supplementary descriptor may be empty, in which case a Joliet one is derived from the primary.
bool Jazz2:: AssetPacker:: Iso9660Builder:: AddDirectoryFromDisk(StringView path,
StringView hostPath,
LeaveOutFunc leaveOut = nullptr)
Adds a directory and everything below it from the file system.
| Parameters | |
|---|---|
| path | Where it goes in the volume |
| hostPath | The directory in the file system |
| leaveOut | What of it is left out, or nullptr for nothing |
std:: uint32_t Jazz2:: AssetPacker:: Iso9660Builder:: FindFileLba(StringView path,
std:: uint32_t volumeSectorCount)
Absolute address the contents of a file are going to be written at.
The volume is laid out exactly as Write() lays it out over the same number of sectors, which is what a system area that points into the volume — the header of a GameCube disc, which names the sector its executable starts at — has to be completed with before it is written. Returns 0 if there is no such file or the volume does not fit.
bool Jazz2:: AssetPacker:: Iso9660Builder:: Write(ISectorSink& sink,
std:: uint32_t volumeSectorCount,
ISectorReader& imageReader)
Lays the volume out over the specified number of sectors and writes it.
| Parameters | |
|---|---|
| sink | Receives every sector of the volume, from the first one |
| volumeSectorCount | How long the volume is, at least GetRequiredSectorCount() sectors |
| imageReader | Provides the sectors of files added by AddFileFromImage() |