archive

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package archive contains a couple of helper functions for reading RDF files directly from an archive location such as a directory or .tar archive file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromDirectory

func FromDirectory(baseDir string, id int) (*pgrdf.Ebook, error)

FromDirectory will lookup the .rdf from the given base directory and PG eText number. If lookup speed is important, then this method is faster than using a .tar archive, at the cost of disk space.

NOTE: the directory structure must be exactly as extracted from the archive:

rdf_files/
├─ cache/
│  └─ epub/
│     ├─ 1/
│     │  └─ pg1.rdf
│     ├─ 2/
│     ...

The base dir "rdf_files" would be given with the eText id "1".

func FromTarArchive

func FromTarArchive(archiveFile io.Reader, id int) (*pgrdf.Ebook, error)

FromTarArchive will read the .rdf file from the official Project Gutenberg archive, which contain the standard PG directory structure, i.e. `cache/epub/11/pg11.rdf`.

These are currently available in two archive types:

rdf-files.tar.bz2
rdf-files.tar.zip

Reading from bz2/zip is considerably slower than just from the plain tar, so it is recommended to first extract the tar from the bz2/zip archive.

$ bzip2 -dk rdf-files.tar.bz2

If using the bz2/zip directly is required, then the `.tar.bz2` must first be wrapped in a bzip2 reader, before calling the function:

FromTarArchive(bzip2.NewReader(archiveFile), id)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL