Documentation
¶
Overview ¶
Package common is the common functions and types for the packer and unpacker packages.
Index ¶
- Constants
- Variables
- func AddFileToFolder(fold *Folder, f *File) error
- func AddFolderToFolder(dest *Folder, src *Folder) error
- func ClearDirinfo()
- func RemoveDirReq(dir string) error
- func SetOffset(offset uint32, hash []byte)
- func ToBinary(h *Header) []byte
- type ContainerType
- type DataHeader
- type DataRecord
- type Dirinfo
- type File
- type Folder
- type FolderRecord
- type Foldernode
- type FoldersHeader
- type Header
- type Offset
- type Packable
Constants ¶
const ( // FFolder is the bit for folder record FFolder uint8 = 0 // FArchive is the bit for archive represented folder FArchive uint8 = 1 // FData is the bit for file record FData uint8 = 2 )
Variables ¶
var ( // Order is the used binary endian order Order = binary.BigEndian )
Functions ¶
func AddFileToFolder ¶
AddFileToFolder will add File object to Folder object
func AddFolderToFolder ¶
AddFolderToFolder will add subfolder Folder object into Folder object
func RemoveDirReq ¶
RemoveDirReq will remove folder reqursively.
based on https://stackoverflow.com/questions/33450980/golang-remove-all-contents-of-a-directory
Types ¶
type ContainerType ¶
ContainerType is the type of container
func IsContainer ¶
func IsContainer(filename string) (*ContainerType, bool)
IsContainer check file name for .zip or .jar extensions
type DataHeader ¶
type DataHeader []*DataRecord
DataHeader is the array of the pointers to the DataRecord objects.
type DataRecord ¶
type DataRecord struct { Offset uint32 `json:"offset"` Size uint32 `json:"size"` Hash []byte `json:"hash"` }
DataRecord is the type for file representation in archive header.
type Dirinfo ¶
Dirinfo is the hash to files map, used as basic structure for output file header.
func GetDirinfo ¶
func GetDirinfo() *Dirinfo
GetDirinfo will return current state of the DirInfo object
type File ¶
File is the representation of the file entity. This type contains filename, filesize and hashsumm.
type Folder ¶
type Folder struct { IsContainer bool `json:"isContainer"` Name string `json:"name"` Folders []*Folder `json:"folders"` Files []*File `json:"files"` }
Folder is the representation of the disk folder OR archive.
type FolderRecord ¶
type FolderRecord struct { Parent uint32 `json:"parentId"` Flags uint8 `json:"flags"` Data uint32 `json:"dataId"` Namelength uint8 `json:"namelen"` Name []byte `json:"name"` }
FolderRecord is the type for folder representation in archive header.
type Foldernode ¶
Foldernode is the interface, defined is the object has subfolder with the given name.
type FoldersHeader ¶
type FoldersHeader []FolderRecord
FoldersHeader is the array of the FolderRecord objects
type Header ¶
type Header struct { Folders FoldersHeader `json:"folders"` Data DataHeader `json:"data"` Size uint32 `json:"datasize"` }
Header is the structure of the archive header information.
func FromBinary ¶
FromBinary will parse bytes array into new Header object
func (*Header) FindDataOffset ¶
FindDataOffset will find data offset by hash of the given File object.
func (*Header) Fold ¶
Fold will create new Folder record in header and link it with parent folder by parentID
type Offset ¶
Offset is the file hashes by 4 bytes of file offset in _uncompressed_ data array.
func GetOffsets ¶
func GetOffsets() *Offset
GetOffsets will return current state of the Offsets object