Skip to content

Documentation / base / GenericHtmlDirectoryReader

Class: GenericHtmlDirectoryReader

Defined in: libs/base/src/vfs/readers/generic_html_index_reader.ts:21

A generic HTML directory reader that parses index-style HTML pages to list directory entries (files and subdirectories).

Remarks

  • Targets simple directory listings produced by common HTTP servers (e.g., Apache, Nginx).
  • Extracts entries from <a> elements and attempts to infer size and modified time from surrounding table rows or text content.
  • Skips external links, parent-directory links, and anchors.
  • Normalizes and resolves paths using the provided HttpDirectoryReaderContext.

Limitations:

  • Parsing depends on the server’s HTML structure; non-standard listings may yield incomplete metadata.
  • Size/mtime extraction uses best-effort heuristics and may be unavailable for some servers.

Implements

Constructors

Constructor

new GenericHtmlDirectoryReader(): GenericHtmlDirectoryReader

Returns

GenericHtmlDirectoryReader

Properties

name

readonly name: "generic-html" = 'generic-html'

Defined in: libs/base/src/vfs/readers/generic_html_index_reader.ts:22

Human-readable name of this reader implementation (for diagnostics/logging).

Implementation of

HttpDirectoryReader.name

Methods

readOnce()

readOnce(dirPath, ctx): Promise<FileMetadata[]>

Defined in: libs/base/src/vfs/readers/generic_html_index_reader.ts:24

Performs a single-pass listing of the directory at dirPath.

Requirements:

  • Return only direct children of dirPath (non-recursive).
  • Populate FileMetadata fields as accurately as possible (name, path, type, size, timestamps, mimeType).
  • Use ctx.normalizePath/ctx.joinPath to build stable path fields.

Error handling:

  • Throw on unrecoverable errors (the host VFS may fall back to other readers).
  • Return an empty array if the directory is valid but contains no entries.

Parameters

dirPath

string

Normalized directory path to read (typically ends with "/").

ctx

HttpDirectoryReaderContext

Context utilities for network and path operations.

Returns

Promise<FileMetadata[]>

A promise resolving to a flat list of file/directory metadata.

Implementation of

HttpDirectoryReader.readOnce

Released under the MIT License.