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.
52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
'use strict';
|
|
|
|
const createBufferReader = require("../buffer-reader");
|
|
const roundEven = require("../../round-even");
|
|
const createBitParser = require("../../bit-parser");
|
|
const decode = require("../decode");
|
|
|
|
/* 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.
|
|
*/
|
|
|
|
let parseFileFlags = createBitParser([
|
|
"hidden",
|
|
"directory",
|
|
"associated",
|
|
"inEAR",
|
|
"permissionsInEAR",
|
|
null,
|
|
null,
|
|
"moreRecordsFollowing"
|
|
]);
|
|
|
|
module.exports = function parseDirectoryRecord(data, {encoding} = {encoding: "ascii"}) {
|
|
let bufferReader = createBufferReader(data, {encoding: encoding});
|
|
|
|
let identifierLength = bufferReader.int8(32);
|
|
let identifierEnd = roundEven(32 + identifierLength);
|
|
|
|
return {
|
|
encoding: encoding,
|
|
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!
|
|
}
|
|
};
|