lake

package module
v0.0.0-...-cc4284e Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 3 Imported by: 7

README

lake

Build Status GoDoc MIT licensed No Maintenance Intended

lake deals with files and pools. It is used mostly by https://github.com/itchio/wharf

It is developed for internal use, I don't intend to take pull requests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaseFix

type CaseFix struct {
	// Case we found on disk, which was wrong
	Old string
	// Case we renamed it to, which is right
	New string
}

func (CaseFix) Apply

func (cf CaseFix) Apply(entryPath string) (string, bool)

type CaseFixParams

type CaseFixParams struct {
	Stats    *CaseFixStats
	Consumer *state.Consumer
}

type CaseFixStats

type CaseFixStats struct {
	Fixes []CaseFix
}

type CaseFixerPool

type CaseFixerPool interface {
	// FixExistingCase is ugly, but so is the real world.
	//
	// It collects all the paths in the pool's container, and
	// from shortest to longest, makes sure that they have the
	// case we expected.
	//
	// For example, if we have container with files:
	//   - Foo/Bar
	// And directories:
	//   - Foo/
	// But on disk, we have:
	//   - FOO/bar
	//
	// This would rename `FOO` to `Foo`,
	// and `Foo/bar` to `Foo/Bar`.
	FixExistingCase(params CaseFixParams) error
}

type Pool

type Pool interface {
	// GetSize returns the size of a given file entry, as specified by the container
	// the pool was built with.
	GetSize(fileIndex int64) int64

	// GetReader returns a Reader for a given file. Typically, readers are cached,
	// so a second call to GetReader will close the last reader.
	GetReader(fileIndex int64) (io.Reader, error)

	// GetReadSeeker beahves like GetReader (including caching) but allows seeking
	// as well. For some pools (like zip pool), this call may involve decompressing
	// *an entire entry* and then returning a temporary *os.File (or memory file).
	GetReadSeeker(fileIndex int64) (io.ReadSeeker, error)

	// Close closes the last opened reader, if any. Does not impact `GetWriter`
	// at all. Calling Close doesn't render the pool unusable, all its other methods
	// should not error out afterwards.
	Close() error
}

A Pool gives read+seek access to an ordered list of files, by index

type WritablePool

type WritablePool interface {
	Pool

	// GetWriter returns a writer for a given file entry
	// This also truncates the file on disk (or whatever the pool represents),
	// so that the file's final size is the number of bytes written on close.
	// Writers aren't cached, so this can be called concurrently.
	GetWriter(fileIndex int64) (io.WriteCloser, error)
}

A WritablePool adds writing access to the Pool type

Directories

Path Synopsis
Package tlc is a generated protocol buffer package.
Package tlc is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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