Change name to be name and extension and make base name the file name without the extension

This commit is contained in:
Jordan Goulder 2025-01-20 11:14:22 -05:00
parent f49754928e
commit 18c5554211

View File

@ -42,6 +42,7 @@ export interface IAttributes {
export interface IStandardDirEntry {
type: 'standard-entry'
name: string
basename: string
extension: string
attributes: IAttributes
size: number
@ -197,16 +198,14 @@ export class FloppyDisk {
continue
}
const fullName = `${entry.name}${entry.extension ? '.' + entry.extension : ''}`
if (entry.name === '.' || entry.name === '..' || entry.attributes.volumeId) {
// do nothing
} else if (entry.attributes.directory) {
listing += `\n<li>${fullName}\\`
listing += `\n<li>${entry.name}\\`
listing = this.addDirectory(listing, entry.subDirEntries)
listing += '</li>\n'
} else {
listing += `\n<li>${fullName}</li>\n`
listing += `\n<li>${entry.name}</li>\n`
}
}
@ -314,11 +313,15 @@ function decodeDirectoryEntry(data: DataView, fd: FloppyDisk): TDirEntry | null
return { type: 'long-filename-entry' }
} else {
const asciiDecoder = new TextDecoder('ascii')
const name = asciiDecoder.decode(data.buffer.slice(data.byteOffset, data.byteOffset + 8)).trim()
const basename = asciiDecoder
.decode(data.buffer.slice(data.byteOffset, data.byteOffset + 8))
.trim()
const extension = asciiDecoder
.decode(data.buffer.slice(data.byteOffset + 8, data.byteOffset + 11))
.trim()
const name = basename + (extension ? '.' + extension : '')
const attributeByte = data.getUint8(11)
const attributes: IAttributes = {
@ -336,6 +339,7 @@ function decodeDirectoryEntry(data: DataView, fd: FloppyDisk): TDirEntry | null
const entry: IStandardDirEntry = {
type: 'standard-entry',
name,
basename,
extension,
attributes,
firstCluster,