From 18c5554211a2a6c493b1a46d985556cdca1022a1 Mon Sep 17 00:00:00 2001 From: Jordan Goulder Date: Mon, 20 Jan 2025 11:14:22 -0500 Subject: [PATCH] Change name to be name and extension and make base name the file name without the extension --- src/floppy/disk.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/floppy/disk.ts b/src/floppy/disk.ts index 806af76..d085e78 100644 --- a/src/floppy/disk.ts +++ b/src/floppy/disk.ts @@ -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
  • ${fullName}\\` + listing += `\n
  • ${entry.name}\\` listing = this.addDirectory(listing, entry.subDirEntries) listing += '
  • \n' } else { - listing += `\n
  • ${fullName}
  • \n` + listing += `\n
  • ${entry.name}
  • \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,