Add more inforation to directory entry
This commit is contained in:
parent
cfa42a5cb9
commit
442253b953
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user