pack

package
v0.0.0-...-da9a50a Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoCompression = 0
	Deflate       = 8
)

NoCompression means Store

View Source
const ManifestLocation = "manifest.json"

ManifestLocation is the path if the Readium manifest in a package

View Source
const RWPManifestName = "manifest.json"

RWPManifestName is the name of the Readium Manifest in a package

View Source
const W3CEntryPageName = "index.html"

W3CEntryPageName is the name of the W3C entry page in an LPF package

View Source
const W3CManifestName = "publication.json"

W3CManifestName is the name of the W3C manifest in an LPF package

Variables

This section is empty.

Functions

func BuildRPFFromLPF

func BuildRPFFromLPF(lpfPath string, rwppPath string) error

BuildRPFFromLPF builds a Readium package (rwpp) from a W3C LPF file (lpfPath)

func BuildRPFFromPDF

func BuildRPFFromPDF(title string, inputPath string, outputPath string) error

BuildRPFFromPDF builds a Readium Package (rwpp) which embeds a PDF file

func Do

func Do(encrypter crypto.Encrypter, ep epub.Epub, w io.Writer) (enc *xmlenc.Manifest, key crypto.ContentKey, err error)

Do encrypts when necessary the resources of an EPUB package It is called for EPUB files only FIXME: try to merge Process() and Do()

func FindFile

func FindFile(name string, ep epub.Epub) (*epub.Resource, bool)

FindFile finds a file in an EPUB object

func Process

func Process(profile license.EncryptionProfile, encrypter crypto.Encrypter, reader PackageReader, writer PackageWriter) (key crypto.ContentKey, err error)

Process copies resources from the source to the destination package, after encryption if needed.

func UnzipToFolder

func UnzipToFolder(src string, dest string) ([]string, error)

UnzipToFolder fills a folder (dest) with the content of a zip file (src) returns an array of unzipped file names

Types

type EncryptedFileInfo

type EncryptedFileInfo struct {
	File   *os.File
	Size   int64
	Sha256 string
}

EncryptedFileInfo contains a file, its size and sha256

type ManualSource

type ManualSource struct {
	// contains filtered or unexported fields
}

ManualSource is a struc

func (*ManualSource) Feed

func (s *ManualSource) Feed(ch chan<- *Task)

Feed is a struc

func (*ManualSource) Post

func (s *ManualSource) Post(t *Task) Result

Post is a struc

type NopWriteCloser

type NopWriteCloser struct {
	io.Writer
}

NopWriteCloser object

func (*NopWriteCloser) Close

func (nc *NopWriteCloser) Close() error

Close closes a NopWriteCloser

type PackageReader

type PackageReader interface {
	Resources() []Resource
	NewWriter(io.Writer) (PackageWriter, error)
}

PackageReader is an interface

type PackageWriter

type PackageWriter interface {
	NewFile(path string, contentType string, storageMethod uint16) (io.WriteCloser, error)
	MarkAsEncrypted(path string, originalSize int64, profile license.EncryptionProfile, algorithm string)
	Close() error
}

PackageWriter is an interface

type Packager

type Packager struct {
	Incoming chan *Task
	// contains filtered or unexported fields
}

Packager is a struct

func NewPackager

func NewPackager(store storage.Store, idx index.Index, concurrency int) *Packager

NewPackager waits for incoming EPUB files, encrypts them and adds them to the store

type RPFReader

type RPFReader struct {
	// contains filtered or unexported fields
}

RPFReader is a Readium Package reader

func NewRPFReader

func NewRPFReader(zipReader *zip.Reader) (*RPFReader, error)

NewRPFReader creates a new Readium Package reader

func OpenRPF

func OpenRPF(name string) (*RPFReader, error)

OpenRPF opens a Readium Package and returns a zip reader + a manifest

func (*RPFReader) NewWriter

func (reader *RPFReader) NewWriter(writer io.Writer) (PackageWriter, error)

NewWriter returns a new PackageWriter writing a RWP to the output file

func (*RPFReader) Resources

func (reader *RPFReader) Resources() []Resource

Resources returns a list of all resources which may be encrypted It is part of the PackageReader interface. Note: the current design choice is to leave ancillary resources (in "resources" and "alternates") unencrypted FIXME: add "resources" and "alternates" to the slice

type RPFWriter

type RPFWriter struct {
	// contains filtered or unexported fields
}

RPFWriter is a Readium Package writer

func (*RPFWriter) Close

func (writer *RPFWriter) Close() error

Close closes a Readium Package Writer

func (*RPFWriter) MarkAsEncrypted

func (writer *RPFWriter) MarkAsEncrypted(path string, originalSize int64, profile license.EncryptionProfile, algorithm string)

MarkAsEncrypted marks a resource as encrypted (with an lcp profile and algorithm), in the writer manifest FIXME: currently only looks into the reading order. Add "alternates", think about adding "resources" FIXME: process resources which are compressed before encryption -> add Compression and OriginalLength properties in this case

func (*RPFWriter) NewFile

func (writer *RPFWriter) NewFile(path string, contentType string, storageMethod uint16) (io.WriteCloser, error)

NewFile creates a header in the zip archive and adds an entry to the writer reading order if missing. This function is called in two main cases: - one is the creation of a Readium Package for a PDF file (no existing entry in the manifest) - another in the encryption of an existing Readium Package (there is already an entry in the manifest) FIXME: the PackageWriter interface is obscure; let's make it better.

type Resource

type Resource interface {
	Path() string
	Size() int64
	ContentType() string
	CompressBeforeEncryption() bool
	CanBeEncrypted() bool
	Encrypted() bool
	CopyTo(PackageWriter) error
	Open() (io.ReadCloser, error)
}

Resource is an interface

type Result

type Result struct {
	Error   error
	ID      string
	Elapsed time.Duration
}

Result is a result

type Source

type Source interface {
	Feed(chan<- *Task)
}

Source in an interface

type Task

type Task struct {
	Name string
	Body io.ReaderAt
	Size int64
	// contains filtered or unexported fields
}

Task is an interface

func NewTask

func NewTask(name string, body io.ReaderAt, size int64) *Task

NewTask generates a new task

func (*Task) Done

func (t *Task) Done(r Result)

Done returns a result

func (*Task) Wait

func (t *Task) Wait() Result

Wait returns a result

Jump to

Keyboard shortcuts

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