links method

  1. @override
Future<List<Link>> links()

Known resources available in the medium, such as file paths on the file system or entries in a ZIP archive. This list is not exhaustive, and additional unknown resources might be reachable.

If the medium has an inherent resource order, it should be followed. Otherwise, HREFs are sorted alphabetically.


Future<List<Link>> links() async {
  List<Link> files = [];
  for (MapEntry<String, FileSystemEntity> entry in paths.entries) {
    String href = entry.key;
    if (entry.value is Directory) {
      Directory directory = entry.value as Directory;
      await directory
          .list(recursive: true)
          .then((List<FileSystemEntity> files) => files
              .map((f) async => await _toLink(href, f, entry.value)))
          .then((futures) => Future.wait(futures))
          .then((list) => files.addAll(list));
    } else if (entry.value is File) {
      File file = entry.value as File;
      files.add(await _toLink(href, file, file));
  return files;