getEpubRootFilePath function

Future<String?> getEpubRootFilePath(
  1. Archive epubArchive
)

Retrieves the root file path of the EPUB from the provided archive.

The function first gets the container file entry from the archive, then parses it into an XML document. It then gets the package element from the container document and retrieves the root file path from the package.

epubArchive is the archive from which to retrieve the root file path.

Returns a Future that completes with the root file path of the EPUB, or null if the root file path could not be found.

Implementation

Future<String?> getEpubRootFilePath(final Archive epubArchive) async {
  final containerFileEntry = _getContainerFileEntry(epubArchive);
  final containerDocument = XmlDocument.parse(convert.utf8.decode(
    containerFileEntry.content as List<int>,
  ));

  final package = _getPackageElement(containerDocument);
  return _getRootFilePath(package);
}