'use strict'; const createBufferReader = require("../../buffer-reader"); const parseDirectoryRecord = require("../directory-record"); module.exports = function parsePrimaryVolumeDescriptor(data, encoding = "ascii") { let bufferReader = createBufferReader(data, { encoding: encoding }); /* NOTE: Technically, the spec states that we should use strA and strD in a primary volume descriptor, and not strA1 and strD1. However, using the encoding-specific versions makes it easier to base the supplementary volume descriptor parser on this one, and since this parser defaults to an 'ascii' encoding anyway, it doesn't matter from a functional perspective. */ return { systemIdentifier: bufferReader.strA1(1, 32), volumeIdentifier: bufferReader.strD1(33, 32), sectorCount: bufferReader.int32_LSB_MSB(73), setSize: bufferReader.int16_LSB_MSB(113), sequenceNumber: bufferReader.int16_LSB_MSB(117), sectorSize: bufferReader.int16_LSB_MSB(121), pathTableSize: bufferReader.int32_LSB_MSB(125), pathTableLocationL: bufferReader.int32_LSB(133), // FIXME: Pointer? (location is expressed in 'sectors') optionalPathTableLocationL: bufferReader.int32_LSB(137), // FIXME: Pointer? (location is expressed in 'sectors') pathTableLocationM: bufferReader.int32_MSB(141), // FIXME: Pointer? (location is expressed in 'sectors') optionalPathTableLocationM: bufferReader.int32_MSB(145), // FIXME: Pointer? (location is expressed in 'sectors') rootDirectory: parseDirectoryRecord(bufferReader.slice(149, 34), {encoding: encoding}), volumeSetIdentifier: bufferReader.strD1(183, 128), publisherIdentifier: bufferReader.strA1(311, 128), // FIXME: null for unspecified & extended publisher information dataPreparerIdentifier: bufferReader.strA1(439, 128), // FIXME: null for unspecified & extended publisher information applicationIdentifier: bufferReader.strA1(567, 128), // FIXME: null for unspecified & extended publisher information copyrightFile: bufferReader.strD1(695, 36), // FIXME: seek for file, optionally? abstractFile: bufferReader.strD1(732, 36), // FIXME: seek for file, optionally? bibliographicFile: bufferReader.strD1(769, 36), // FIXME: seek for file, optionally? creationDate: bufferReader.decDatetime(806), modificationDate: bufferReader.decDatetime(823), expirationDate: bufferReader.decDatetime(840), effectiveDate: bufferReader.decDatetime(857), fileStructureVersion: bufferReader.int8(874), applicationData: data.slice(876, 876 + 512) } };