packext

package
v0.0.0-...-8817f42 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VersionSupported is the packfile version supported by this package
	VersionSupported uint32 = 2
)

Variables

View Source
var (
	ErrSize    = errors.New("Size Error")
	ErrMiss    = errors.New("Miss")
	ErrKey     = errors.New("Wrony Key Format")
	ErrBadName = errors.New("Bad Pack File Name")
)
View Source
var DefaultOPS = NewOriginPackFiles()
View Source
var (
	ErrOutSize = errors.New("Out of Size")
)
View Source
var (
	ErrorNoFind = errors.New("No Find")
)
View Source
var MaxSelect maxSelect
View Source
var SortMode = "size"

Functions

func BuildIdxFile

func BuildIdxFile(fn string) (oerr error)

func DefaultFromDir

func DefaultFromDir(dir string) error

func DupObjectInFile

func DupObjectInFile(fn string) (oerr error)

func Flush

func Flush(m Packer) error
func Footer(m Packer) error

func GetOffsetNoClassify

func GetOffsetNoClassify(idxf string) (op OriginPackFile, objs []ObjEntry, err error)

func NewIdx

func NewIdx(idxf string) (*idxfile.MemoryIndex, error)

func Reidx

func Reidx(packf string) (hs string, err error)

func TravelPackFile

func TravelPackFile(fn string, cb func(o uint32, h [32]byte, s uint32, r io.ReadSeeker) error) (err error)

Types

type ByteClassify

type ByteClassify byte

func (ByteClassify) Hit

func (b ByteClassify) Hit(h types.Hash) bool

func (ByteClassify) NamePrefix

func (b ByteClassify) NamePrefix() string

type Entries

type Entries []*ObjEntry

func (Entries) Len

func (es Entries) Len() int

func (Entries) Less

func (es Entries) Less(i, j int) bool

func (Entries) Swap

func (es Entries) Swap(i, j int)

type FileFinder

type FileFinder interface {
	Hash2FileName(types.Hash) (string, error)
}

type FileMap

type FileMap map[types.Hash]string
var (
	DefaultMap FileMap = make(map[types.Hash]string)
)

func (FileMap) Hash2FileName

func (m FileMap) Hash2FileName(h types.Hash) (string, error)

type HashSelect

type HashSelect types.Hash

func (HashSelect) Determine

func (hash HashSelect) Determine(objs []*ObjEntry) *ObjEntry

type HeadOffset

type HeadOffset struct {
	Head   [32]byte
	Offset uint32
}
type Header struct {
	H *packfile.ObjectHeader
	B *HeaderExt
}

func HeaderFromByte

func HeaderFromByte(raw []byte) (*Header, error)

func NewHeader

func NewHeader(orig, base *ObjEntry) *Header

func (*Header) ToByte

func (h *Header) ToByte() (raw []byte)

type HeaderExt

type HeaderExt [32]byte

func (*HeaderExt) Check

func (h *HeaderExt) Check() bool

func (*HeaderExt) Determine

func (h *HeaderExt) Determine(objs []*ObjEntry) *ObjEntry

func (*HeaderExt) FromFile

func (h *HeaderExt) FromFile(r io.Reader) (err error)

func (*HeaderExt) ToFile

func (h *HeaderExt) ToFile(w io.Writer) (err error)

func (*HeaderExt) ToObjEntry

func (h *HeaderExt) ToObjEntry() (*ObjEntry, error)

type IdxObj

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

func NewIdxObj

func NewIdxObj(idxf string) (r *IdxObj, err error)

func (*IdxObj) BuildHead

func (idx *IdxObj) BuildHead(o *ObjEntry) (head []byte, err error)

func (*IdxObj) Close

func (idx *IdxObj) Close() error

func (*IdxObj) GetBase

func (idx *IdxObj) GetBase(o *ObjEntry) (*ObjEntry, error)

func (*IdxObj) Next

func (idx *IdxObj) Next(cb func(o *ObjEntry, h, b []byte) error) (err error)

func (*IdxObj) Reset

func (idx *IdxObj) Reset(v bool)

func (*IdxObj) ResolveRealType

func (idx *IdxObj) ResolveRealType(o *ObjEntry) error

type MergeFile

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

func NewMergeFile

func NewMergeFile(dir string) (*MergeFile, error)

func (*MergeFile) AddFile

func (m *MergeFile) AddFile(fn string, limit uint64) error

func (*MergeFile) Close

func (m *MergeFile) Close() error

func (*MergeFile) Dir

func (m *MergeFile) Dir() string

func (*MergeFile) Do

func (m *MergeFile) Do() error

func (*MergeFile) Hash

func (m *MergeFile) Hash() (plumbing.Hash, error)

func (*MergeFile) Head

func (m *MergeFile) Head() error

type MergeNoFile

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

func NewMergeNoFile

func NewMergeNoFile(dir string) (*MergeNoFile, error)

func (*MergeNoFile) AddFile

func (m *MergeNoFile) AddFile(idxf string) error

func (*MergeNoFile) Close

func (m *MergeNoFile) Close()

type ObjEntry

type ObjEntry struct {
	idxfile.Entry
	Size     uint32
	PackFile OriginPackFile
	OHeader  *packfile.ObjectHeader
	RealType plumbing.ObjectType
}

func ExtFromFile

func ExtFromFile(r io.Reader) (obj *ObjEntry, readed int, err error)

func NewOEFromBytes

func NewOEFromBytes(buf []byte) (obj *ObjEntry)

func (*ObjEntry) Bytes

func (obj *ObjEntry) Bytes() []byte

func (*ObjEntry) FromByte

func (obj *ObjEntry) FromByte(v []byte) error

func (*ObjEntry) Key

func (obj *ObjEntry) Key() []byte

func (*ObjEntry) SetKey

func (obj *ObjEntry) SetKey(v []byte) error

func (*ObjEntry) ToByte

func (obj *ObjEntry) ToByte() []byte

func (*ObjEntry) ToHeaderExt

func (obj *ObjEntry) ToHeaderExt() (buf HeaderExt)

type ObjectGet

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

func NewObjectGet

func NewObjectGet(g types.PackDataGeter) *ObjectGet

func (*ObjectGet) Body

func (og *ObjectGet) Body(oh types.Hash) ([]byte, error)

func (*ObjectGet) Get

func (og *ObjectGet) Get(oh types.Hash) ([]byte, types.Hash, error)

func (*ObjectGet) Header

func (og *ObjectGet) Header() (*packfile.ObjectHeader, error)

func (*ObjectGet) HeaderByHash

func (og *ObjectGet) HeaderByHash(oh types.Hash) (*packfile.ObjectHeader, error)

func (*ObjectGet) Reader

func (og *ObjectGet) Reader() io.Reader

type OriginPackFile

type OriginPackFile types.Hash

func (OriginPackFile) Less

func (OriginPackFile) NewEmptyEntry

func (o OriginPackFile) NewEmptyEntry() *ObjEntry

func (OriginPackFile) NewEntry

func (o OriginPackFile) NewEntry(e *idxfile.Entry) *ObjEntry

func (OriginPackFile) String

func (o OriginPackFile) String() string

type OriginPackFiles

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

func NewOriginPackFiles

func NewOriginPackFiles() OriginPackFiles

func (OriginPackFiles) GetFileName

func (ops OriginPackFiles) GetFileName(hash OriginPackFile) (string, error)

func (OriginPackFiles) GetHash

func (ops OriginPackFiles) GetHash(fn string) (OriginPackFile, error)

type PackEncodeFile

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

func NewPack

func NewPack(fn string) (*PackEncodeFile, error)

func (*PackEncodeFile) Close

func (pf *PackEncodeFile) Close() error

func (*PackEncodeFile) Do

func (pf *PackEncodeFile) Do(r io.Reader, size int64) (int64, error)

func (*PackEncodeFile) DoBody

func (pf *PackEncodeFile) DoBody(r io.Reader) (int64, error)

func (*PackEncodeFile) DoHead

func (pf *PackEncodeFile) DoHead(oh *packfile.ObjectHeader) (int64, error)

func (*PackEncodeFile) Footer

func (pf *PackEncodeFile) Footer() (plumbing.Hash, error)

func (*PackEncodeFile) Head

func (pf *PackEncodeFile) Head(numEntries int) error

type PackFile

type PackFile struct {
	H    *os.File
	Lock sync.Mutex
	Hash types.Hash
	Hit  int
}

func NewPackFileFromFN

func NewPackFileFromFN(fn string, h types.Hash) (*PackFile, error)

func (*PackFile) Close

func (pf *PackFile) Close() error

func (*PackFile) Get

func (pf *PackFile) Get(e *ObjEntry) ([]byte, error)

type PackFileAndDB

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

func NewFileDirPFDB

func NewFileDirPFDB(db types.DBer, dir string) (*PackFileAndDB, error)

func (*PackFileAndDB) Get

func (p *PackFileAndDB) Get(h types.Hash) ([]byte, types.Hash, error)

type PackFiles

type PackFiles struct {
	Opened      map[types.Hash]*PackFile
	MaxOpen     int
	GetFileName FileFinder
}

func NewPackFiles

func NewPackFiles(finder FileFinder) *PackFiles

func (*PackFiles) Get

func (ps *PackFiles) Get(e *ObjEntry) ([]byte, error)

func (*PackFiles) NewPackFile

func (ps *PackFiles) NewPackFile(h types.Hash) (*PackFile, error)

type Packer

type Packer interface {
	Head() error
	Do() error
	Close() error
	Hash() (plumbing.Hash, error)
	Dir() string
}

type Packns

type Packns struct {
	Servered []types.Classifer
	Ids      []types.Indexes
	Pfs      []*os.File
	Dir      string
}

func NewPackNo

func NewPackNo(s []byte, d string) (r *Packns, err error)

func (*Packns) Close

func (r *Packns) Close() (err error)

func (*Packns) GetAnyHash

func (r *Packns) GetAnyHash(hash types.Hash) (body []byte, d bool, base [32]byte, err error)

func (*Packns) GetByHash

func (r *Packns) GetByHash(hash types.Hash) (head map[int][]HeadOffset, err error)

func (*Packns) GetHashAndLen

func (r *Packns) GetHashAndLen(h [32]byte, head map[int][]HeadOffset) (body []byte, deta bool, base [32]byte, err error)

func (*Packns) GetRawByHash

func (r *Packns) GetRawByHash(hash types.Hash) (raw []byte, err error)

func (*Packns) GetRawSpecial

func (r *Packns) GetRawSpecial(h [32]byte) (raw []byte, err error)

func (*Packns) GetSpecial

func (r *Packns) GetSpecial(h [32]byte) (body []byte, d bool, base [32]byte, err error)

type Scanner

type Scanner struct {
	packfile.Scanner
}

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Close

func (s *Scanner) Close() error

func (*Scanner) ObjectHeaderAtOffset

func (s *Scanner) ObjectHeaderAtOffset(offset int64) (*packfile.ObjectHeader, error)

type SelectFile

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

func NewSelectFile

func NewSelectFile(dir string, objs []string, g *ObjectGet) (*SelectFile, error)

func (*SelectFile) Close

func (m *SelectFile) Close() error

func (*SelectFile) Dir

func (m *SelectFile) Dir() string

func (*SelectFile) Do

func (m *SelectFile) Do() (err error)

func (*SelectFile) Hash

func (m *SelectFile) Hash() (plumbing.Hash, error)

func (*SelectFile) Head

func (m *SelectFile) Head() error

type Selector

type Selector interface {
	Determine([]*ObjEntry) *ObjEntry
}

type SplitIdx

type SplitIdx []types.Classifer

func DefaultByteSplit

func DefaultByteSplit() SplitIdx

func (SplitIdx) GetOffset

func (s SplitIdx) GetOffset(idxf string) (objs [][]ObjEntry, err error)

func (SplitIdx) NamePrefix

func (s SplitIdx) NamePrefix(k int) (string, error)

func (SplitIdx) Number

func (s SplitIdx) Number(hash plumbing.Hash) (hs []int)

Jump to

Keyboard shortcuts

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