Add more inforation to directory entry

This commit is contained in:
Jordan Goulder 2025-01-15 15:07:23 -05:00
parent cfa42a5cb9
commit 442253b953

View File

@ -30,10 +30,22 @@ export interface IBiosParameterBlock {
totalSectorsLarge: number totalSectorsLarge: number
} }
export interface IAttributes {
readOnly: boolean
hidden: boolean
system: boolean
volumeId: boolean
directory: boolean
archive: boolean
}
export interface IStandardDirEntry { export interface IStandardDirEntry {
type: 'standard-entry' type: 'standard-entry'
name: string name: string
extension: string extension: string
attributes: IAttributes
size: number
firstCluster: number
} }
export interface ILongFileNameDirEntry { export interface ILongFileNameDirEntry {
@ -229,10 +241,28 @@ function decodeDirectoryEntry(data: DataView): DirEntry | null {
const extension = asciiDecoder.decode( const extension = asciiDecoder.decode(
data.buffer.slice(data.byteOffset + 8, data.byteOffset + 11), 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 { return {
type: 'standard-entry', type: 'standard-entry',
name, name,
extension, extension,
attributes,
firstCluster,
size,
} }
} }
} }