From 442253b953e78b21e652d81273d7caf8dab8c225 Mon Sep 17 00:00:00 2001 From: Jordan Goulder Date: Wed, 15 Jan 2025 15:07:23 -0500 Subject: [PATCH] Add more inforation to directory entry --- src/floppy/disk.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/floppy/disk.ts b/src/floppy/disk.ts index a91cfde..6bc0269 100644 --- a/src/floppy/disk.ts +++ b/src/floppy/disk.ts @@ -30,10 +30,22 @@ export interface IBiosParameterBlock { totalSectorsLarge: number } +export interface IAttributes { + readOnly: boolean + hidden: boolean + system: boolean + volumeId: boolean + directory: boolean + archive: boolean +} + export interface IStandardDirEntry { type: 'standard-entry' name: string extension: string + attributes: IAttributes + size: number + firstCluster: number } export interface ILongFileNameDirEntry { @@ -229,10 +241,28 @@ function decodeDirectoryEntry(data: DataView): DirEntry | null { const extension = asciiDecoder.decode( data.buffer.slice(data.byteOffset + 8, data.byteOffset + 11), ) + + const attributeByte = data.getUint8(11) + + const attributes: IAttributes = { + readOnly: (attributeByte & 0x01) !== 0, + hidden: (attributeByte & 0x02) !== 0, + system: (attributeByte & 0x04) !== 0, + volumeId: (attributeByte & 0x08) !== 0, + directory: (attributeByte & 0x10) !== 0, + archive: (attributeByte & 0x20) !== 0, + } + + const firstCluster = (data.getUint16(20, true) << 16) | data.getUint16(26, true) + const size = data.getUint32(28, true) + return { type: 'standard-entry', name, extension, + attributes, + firstCluster, + size, } } }