You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB
JavaScript

'use strict';
const createBufferReader = require("../buffer-reader");
const roundEven = require("../../round-even");
function parseFileFlags(value) {
/* File flags: (ref http://wiki.osdev.org/ISO_9660#Directories)
* Bit Description
* 0 If set, the existence of this file need not be made known to the user (basically a 'hidden' flag.
* 1 If set, this record describes a directory (in other words, it is a subdirectory extent).
* 2 If set, this file is an "Associated File".
* 3 If set, the extended attribute record contains information about the format of this file.
* 4 If set, owner and group permissions are set in the extended attribute record.
* 5 & 6 Reserved
* 7 If set, this is not the final directory record for this file (for files spanning several extents, for example files over 4GiB long.
*/
return {
hidden: !!(value & 1),
directory: !!(value & 2),
associated: !!(value & 4),
inEAR: !!(value & 8),
permissionsInEAR: !!(value & 16),
moreRecordsFollowing: !!(value & 128)
}
}
module.exports = function parseDirectoryRecord(data) {
let bufferReader = createBufferReader(data);
let identifierLength = bufferReader.int8(32);
let identifierEnd = roundEven(32 + identifierLength);
return {
recordLength: bufferReader.int8(0),
extendedAttributeRecordLength: bufferReader.int8(1),
extentLocation: bufferReader.int32_LSB_MSB(2),
extentSize: bufferReader.int32_LSB_MSB(10),
recordingDate: bufferReader.directoryDatetime(18),
fileFlags: parseFileFlags(bufferReader.int8(25)),
interleavedUnitSize: bufferReader.int8(26),
interleavedGapSize: bufferReader.int8(27),
sequenceNumber: bufferReader.int16_LSB_MSB(28),
identifierLength: identifierLength,
identifier: bufferReader.strFilename(33, identifierLength),
systemUse: data.slice(identifierEnd, 254) // FIXME: Extensions!
}
};