refactor(iso9660): derive primary volume type from its parser (#17313)

This commit is contained in:
Vincent Koc
2026-12-06 08:13:36 +08:00
committed by GitHub
parent 3e89e187fa
commit ef979c6528
+3 -21
View File
@@ -28,26 +28,7 @@ import {
type ParseFailureError,
} from "../parseFailure.js";
interface PrimaryVolume {
readonly systemIdentifier: string;
readonly volumeIdentifier: string;
readonly volumeSetIdentifier: string;
readonly publisherIdentifier: string;
readonly dataPreparerIdentifier: string;
readonly applicationIdentifier: string;
readonly volumeSpaceSize: number;
readonly volumeSetSize: number;
readonly volumeSequenceNumber: number;
readonly logicalBlockSize: 2048;
readonly pathTableSize: number;
readonly creationDate: string | null;
readonly modificationDate: string | null;
readonly expirationDate: string | null;
readonly effectiveDate: string | null;
readonly primaryRoot: Iso9660DirectoryRecord;
/** Absolute image offset of the primary descriptor. */
readonly offset: number;
}
type PrimaryVolume = Readonly<ReturnType<typeof primaryVolume>>;
/**
* The ISO 9660 volume descriptor set: the primary descriptor, a Joliet
@@ -220,7 +201,7 @@ const jolietLevel = (sector: Buffer): 1 | 2 | 3 | null => {
return null;
};
const primaryVolume = (sector: Buffer, base: number): PrimaryVolume => {
const primaryVolume = (sector: Buffer, base: number) => {
if (sector[6] !== 1)
throw iso9660Malformed(
`primary volume descriptor version ${String(sector[6])} is not 1`,
@@ -230,6 +211,7 @@ const primaryVolume = (sector: Buffer, base: number): PrimaryVolume => {
admitFileStructureVersion(sector, base);
const set = volumeSet(sector, base);
return {
/** Absolute image offset of the primary descriptor. */
offset: base,
systemIdentifier: textField(sector, 8, 40),
volumeIdentifier: textField(sector, 40, 72),