Remove cluster chain from directory entries

This commit is contained in:
Jordan Goulder 2025-01-20 11:19:03 -05:00
parent 9ff9642f65
commit 1497ee2df6

View File

@ -48,7 +48,6 @@ export interface IStandardDirEntry {
attributes: IAttributes attributes: IAttributes
size: number size: number
firstCluster: number firstCluster: number
clusterChain: number[]
subDirEntries: TDirEntry[] subDirEntries: TDirEntry[]
} }
@ -349,20 +348,19 @@ function decodeDirectoryEntry(data: DataView, fd: FloppyDisk): TDirEntry | null
extension, extension,
attributes, attributes,
firstCluster, firstCluster,
clusterChain: [],
size, size,
subDirEntries: [], subDirEntries: [],
} }
if (entry.attributes.directory && entry.name !== '.' && entry.name !== '..') { if (entry.attributes.directory && entry.name !== '.' && entry.name !== '..') {
entry.clusterChain = fd.clusterChain(entry.firstCluster) const clusterChain = fd.clusterChain(entry.firstCluster)
const dataSize = entry.clusterChain.length * fd.bytesPerCluster const dataSize = clusterChain.length * fd.bytesPerCluster
if (dataSize !== 0) { if (dataSize !== 0) {
const entryData = new Uint8Array(dataSize) const entryData = new Uint8Array(dataSize)
for (let i = 0; i < entry.clusterChain.length; i++) { for (let i = 0; i < clusterChain.length; i++) {
const offset = (entry.clusterChain[i] - 2) * fd.bytesPerCluster const offset = (clusterChain[i] - 2) * fd.bytesPerCluster
const view = new Uint8Array(fd.buffer, fd.dataOffset + offset, fd.bytesPerCluster) const view = new Uint8Array(fd.buffer, fd.dataOffset + offset, fd.bytesPerCluster)
entryData.set(view, i * fd.bytesPerCluster) entryData.set(view, i * fd.bytesPerCluster)
} }