Simplify file listing
This commit is contained in:
parent
1497ee2df6
commit
b3c3ce4821
@ -37,19 +37,4 @@ pre {
|
||||
color: #c0c0c0;
|
||||
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>
|
||||
|
||||
@ -192,34 +192,35 @@ export class FloppyDisk {
|
||||
return chain
|
||||
}
|
||||
|
||||
addDirectory(listing: string, entries: TDirEntry[]) {
|
||||
listing += '\n<ul>'
|
||||
|
||||
addDirectory(listing: string, path: string[], entries: TDirEntry[]) {
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const entry = entries[i]
|
||||
if (entry.type !== 'standard-entry') {
|
||||
if (
|
||||
entry.type !== 'standard-entry' ||
|
||||
entry.attributes.volumeId ||
|
||||
entry.name === '..' ||
|
||||
entry.name === '.'
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (entry.name === '.' || entry.name === '..' || entry.attributes.volumeId) {
|
||||
// do nothing
|
||||
} else if (entry.attributes.directory) {
|
||||
listing += `\n<li>${entry.name}\\`
|
||||
listing = this.addDirectory(listing, entry.subDirEntries)
|
||||
listing += '</li>\n'
|
||||
listing += `${path.join('\\') + '\\'}${entry.name}`
|
||||
|
||||
if (entry.attributes.directory) {
|
||||
listing += '\\<br/>'
|
||||
listing = this.addDirectory(listing, [...path, entry.name], entry.subDirEntries)
|
||||
} else {
|
||||
listing += `\n<li>${entry.name}</li>\n`
|
||||
listing += '<br/>'
|
||||
}
|
||||
}
|
||||
|
||||
listing += '\n</ul>'
|
||||
return listing
|
||||
}
|
||||
|
||||
buildFileListing(): string {
|
||||
let listing = '<ul>A:\\'
|
||||
listing += this.addDirectory('', this.rootDirEntries ?? [])
|
||||
listing += '</ul>'
|
||||
let listing = '<p>\\<br/>'
|
||||
listing += this.addDirectory('', [''], this.rootDirEntries ?? [])
|
||||
listing += '</p>'
|
||||
return listing
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user