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