Simplify file listing

This commit is contained in:
Jordan Goulder 2025-01-20 12:51:58 -05:00
parent 1497ee2df6
commit b3c3ce4821
2 changed files with 16 additions and 30 deletions

View File

@ -37,19 +37,4 @@ pre {
color: #c0c0c0; color: #c0c0c0;
border: 1px solid rgba(255, 255, 255, 0.3); border: 1px solid rgba(255, 255, 255, 0.3);
} }
:deep(ul) {
padding: 0;
}
:deep(ul ul) {
padding: 0 0 0 1.5em;
}
:deep(li) {
list-style: none;
line-height: 1.5rem;
margin: 0;
padding: 0;
}
</style> </style>

View File

@ -192,34 +192,35 @@ export class FloppyDisk {
return chain return chain
} }
addDirectory(listing: string, entries: TDirEntry[]) { addDirectory(listing: string, path: string[], entries: TDirEntry[]) {
listing += '\n<ul>'
for (let i = 0; i < entries.length; i++) { for (let i = 0; i < entries.length; i++) {
const entry = entries[i] const entry = entries[i]
if (entry.type !== 'standard-entry') { if (
entry.type !== 'standard-entry' ||
entry.attributes.volumeId ||
entry.name === '..' ||
entry.name === '.'
) {
continue continue
} }
if (entry.name === '.' || entry.name === '..' || entry.attributes.volumeId) { listing += `${path.join('\\') + '\\'}${entry.name}`
// do nothing
} else if (entry.attributes.directory) { if (entry.attributes.directory) {
listing += `\n<li>${entry.name}\\` listing += '\\<br/>'
listing = this.addDirectory(listing, entry.subDirEntries) listing = this.addDirectory(listing, [...path, entry.name], entry.subDirEntries)
listing += '</li>\n'
} else { } else {
listing += `\n<li>${entry.name}</li>\n` listing += '<br/>'
} }
} }
listing += '\n</ul>'
return listing return listing
} }
buildFileListing(): string { buildFileListing(): string {
let listing = '<ul>A:\\' let listing = '<p>\\<br/>'
listing += this.addDirectory('', this.rootDirEntries ?? []) listing += this.addDirectory('', [''], this.rootDirEntries ?? [])
listing += '</ul>' listing += '</p>'
return listing return listing
} }
} }