func TagUint16(val TID) Tag {
	var buf [2]byte
	binary.LittleEndian.PutUint16(buf[:], uint16(val))
	return buf[:]
}
TagUint16 is 16-bit unsigned int tag constructor.
package wpk
import (
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"io/fs"
	"math"
	"path/filepath"
	"strings"
	"time"
)
const (
	Signature = "Whirlwind 3.3 Package   "  
	Prebuild  = "Whirlwind 3.3 Prebuild  "  
)
type (
	TID uint16
	FID uint32
	OFFSET uint64
	SIZE uint64
)
const (
	TIDfid        TID = 0  
	TIDoffset     TID = 1  
	TIDsize       TID = 2  
	TIDpath       TID = 3  
	TIDcreated    TID = 4  
	TIDlastwrite  TID = 5  
	TIDlastaccess TID = 6  
	TIDchange     TID = 7  
	TIDfileattr   TID = 8  
	TIDsys TID = 10  
	TIDcrc32ieee TID = 10  
	TIDcrc32c    TID = 11  
	TIDcrc32k    TID = 12  
	TIDcrc64iso  TID = 14  
	TIDmd5    TID = 20  
	TIDsha1   TID = 21  
	TIDsha224 TID = 22  
	TIDsha256 TID = 23  
	TIDsha384 TID = 24  
	TIDsha512 TID = 25  
	TIDmime     TID = 100  
	TIDlink     TID = 101  
	TIDkeywords TID = 102  
	TIDcategory TID = 103  
	TIDversion  TID = 104  
	TIDauthor   TID = 105  
	TIDcomment  TID = 106  
)
type ErrTag struct {
	What error   
	Key  string  
	TID  TID     
}
func (e *ErrTag) Error() string {
	return fmt.Sprintf("key '%s', tag ID %d: %s", e.Key, e.TID, e.What)
}
func (e *ErrTag) Unwrap() error {
	return e.What
}
var (
	ErrSignPre = errors.New("package is not ready")
	ErrSignBad = errors.New("signature does not pass")
	ErrNoTag    = errors.New("tag with given ID not found")
	ErrNoPath   = errors.New("file name is absent")
	ErrNoFID    = errors.New("file ID is absent")
	ErrNoOffset = errors.New("file offset is absent")
	ErrOutOff   = errors.New("file offset is out of bounds")
	ErrNoSize   = errors.New("file size is absent")
	ErrOutSize  = errors.New("file size is out of bounds")
)
type FileReader interface {
	io.Reader
	io.ReaderAt
	io.Seeker
	Size() int64
}
type NestedFile interface {
	fs.File
	FileReader
}
type NFTOMap map[string]OFFSET
type Tagger interface {
	NFTO() NFTOMap
	NamedTags(string) (TagSlice, bool)
}
type Packager interface {
	DataSize() int64
	Tagger
	OpenTags(TagSlice) (NestedFile, error)
	io.Closer
	fs.SubFS
	fs.StatFS
	fs.GlobFS
	fs.ReadFileFS
	fs.ReadDirFS
}
const (
	HeaderSize = 64
	SignSize = 0x18
	LabelSize = 0x18
)
type Header struct {
	signature [SignSize]byte
	disklabel [LabelSize]byte
	fttoffset OFFSET  
	fttsize   SIZE    
}
func (pack *Header) Label() string {
	var i int
	for ; i < LabelSize && pack.disklabel[i] > 0; i++ {
	}
	return string(pack.disklabel[:i])
}
func (pack *Header) SetLabel(label string) {
	for i := copy(pack.disklabel[:], []byte(label)); i < LabelSize; i++ {
		pack.disklabel[i] = 0  
	}
}
func (pack *Header) FTTOffset() int64 {
	return int64(pack.fttoffset)
}
func (pack *Header) FTTSize() int64 {
	return int64(pack.fttsize)
}
func (pack *Header) DataSize() int64 {
	if pack.fttoffset > HeaderSize {
		return int64(pack.fttoffset - HeaderSize)
	}
	return 0
}
func (pack *Header) ReadFrom(r io.Reader) (n int64, err error) {
	if err = binary.Read(r, binary.LittleEndian, pack.signature[:]); err != nil {
		return
	}
	n += SignSize
	if err = binary.Read(r, binary.LittleEndian, pack.disklabel[:]); err != nil {
		return
	}
	n += LabelSize
	if err = binary.Read(r, binary.LittleEndian, &pack.fttoffset); err != nil {
		return
	}
	n += 8
	if err = binary.Read(r, binary.LittleEndian, &pack.fttsize); err != nil {
		return
	}
	n += 8
	return
}
func (pack *Header) WriteTo(w io.Writer) (n int64, err error) {
	if err = binary.Write(w, binary.LittleEndian, pack.signature[:]); err != nil {
		return
	}
	n += SignSize
	if err = binary.Write(w, binary.LittleEndian, pack.disklabel[:]); err != nil {
		return
	}
	n += LabelSize
	if err = binary.Write(w, binary.LittleEndian, &pack.fttoffset); err != nil {
		return
	}
	n += 8
	if err = binary.Write(w, binary.LittleEndian, &pack.fttsize); err != nil {
		return
	}
	n += 8
	return
}
type Tag []byte
func (t Tag) String() (string, bool) {
	return string(t), true
}
func TagString(val string) Tag {
	return Tag(val)
}
func (t Tag) Bool() (bool, bool) {
	if len(t) == 1 {
		return t[0] > 0, true
	}
	return false, false
}
func TagBool(val bool) Tag {
	var buf [1]byte
	if val {
		buf[0] = 1
	}
	return buf[:]
}
func (t Tag) Byte() (byte, bool) {
	if len(t) == 1 {
		return t[0], true
	}
	return 0, false
}
func TagByte(val byte) Tag {
	var buf = [1]byte{val}
	return buf[:]
}
func (t Tag) Uint16() (TID, bool) {
	if len(t) == 2 {
		return TID(binary.LittleEndian.Uint16(t)), true
	}
	return 0, false
}