Documentation ¶
Index ¶
- Constants
- Variables
- func InitLuaVM(ls *lua.LState)
- func NewPack(ls *lua.LState) int
- func PushPack(ls *lua.LState, v *LuaPackage)
- func RegPack(ls *lua.LState)
- func RegPath(ls *lua.LState)
- func RunLuaVM(fpath string) (err error)
- func TableToTagset(lt *lua.LTable, ts wpk.TagsetRaw) (wpk.TagsetRaw, error)
- func TagToValue(tid wpk.TID, tag wpk.TagRaw) (v lua.LValue, err error)
- func ValueToTID(k lua.LValue) (tid wpk.TID, err error)
- func ValueToTag(tid wpk.TID, v lua.LValue) (tag wpk.TagRaw, err error)
- type ErrKeyUndef
- type ErrProtected
- type LuaPackage
Constants ¶
const ( TTany = iota TTbin TTstr TTbool TTuint TTnum TTtime )
const ISO8601 = "2006-01-02T15:04:05.999Z07:00"
const PackMT = "wpk"
PackMT is "wpk" name of Lua metatable.
Variables ¶
var ( ErrPackOpened = errors.New("package write stream already opened") ErrPackClosed = errors.New("package write stream does not opened") ErrDataClosed = errors.New("package data file is not opened") )
Package writer errors.
var ( ErrBadTagKey = errors.New("tag key type is not number or string") ErrBadTagVal = errors.New("tag value type is not string or boolean or 'tag' userdata") )
Tags identifiers conversion errors.
var ( // compiled binary version, sets by compiler with command // go build -ldflags="-X 'github.com/schwarzlichtbezirk/wpk/luawpk.BuildVers=%buildvers%'" BuildVers string // compiled binary build date, sets by compiler with command // go build -ldflags="-X 'github.com/schwarzlichtbezirk/wpk/luawpk.BuildTime=%buildtime%'" BuildTime string )
var MimeExt = map[string]string{}/* 123 elements not displayed */
MimeExt - map of files extensions and associated MIME types.
var NameTid = map[string]wpk.TID{ "offset": wpk.TIDoffset, "size": wpk.TIDsize, "path": wpk.TIDpath, "fid": wpk.TIDfid, "mtime": wpk.TIDmtime, "atime": wpk.TIDatime, "ctime": wpk.TIDctime, "btime": wpk.TIDbtime, "attr": wpk.TIDattr, "mime": wpk.TIDmime, "crc32": wpk.TIDcrc32c, "crc32ieee": wpk.TIDcrc32ieee, "crc32c": wpk.TIDcrc32c, "crc32k": wpk.TIDcrc32k, "crc64": wpk.TIDcrc64iso, "crc64iso": wpk.TIDcrc64iso, "md5": wpk.TIDmd5, "sha1": wpk.TIDsha1, "sha224": wpk.TIDsha224, "sha256": wpk.TIDsha256, "sha384": wpk.TIDsha384, "sha512": wpk.TIDsha512, "tmbjpeg": wpk.TIDtmbjpeg, "tmbwebp": wpk.TIDtmbwebp, "label": wpk.TIDlabel, "link": wpk.TIDlink, "keywords": wpk.TIDkeywords, "category": wpk.TIDcategory, "version": wpk.TIDversion, "author": wpk.TIDauthor, "comment": wpk.TIDcomment, }
NameTid helps convert Lua-table string keys to associated TID values.
var TidName = func() map[wpk.TID]string { var tn = map[wpk.TID]string{} for name, tid := range NameTid { tn[tid] = name } return tn }()
TidName helps format Lua-tables with string keys associated to TID values.
var TidType = map[wpk.TID]int{ wpk.TIDoffset: TTuint, wpk.TIDsize: TTuint, wpk.TIDpath: TTstr, wpk.TIDfid: TTuint, wpk.TIDmtime: TTtime, wpk.TIDatime: TTtime, wpk.TIDctime: TTtime, wpk.TIDbtime: TTtime, wpk.TIDattr: TTuint, wpk.TIDmime: TTstr, wpk.TIDcrc32ieee: TTbin, wpk.TIDcrc32c: TTbin, wpk.TIDcrc32k: TTbin, wpk.TIDcrc64iso: TTbin, wpk.TIDmd5: TTbin, wpk.TIDsha1: TTbin, wpk.TIDsha224: TTbin, wpk.TIDsha256: TTbin, wpk.TIDsha384: TTbin, wpk.TIDsha512: TTbin, wpk.TIDtmbjpeg: TTbin, wpk.TIDtmbwebp: TTbin, wpk.TIDlabel: TTstr, wpk.TIDlink: TTstr, wpk.TIDkeywords: TTstr, wpk.TIDcategory: TTstr, wpk.TIDversion: TTstr, wpk.TIDauthor: TTstr, wpk.TIDcomment: TTstr, }
TidType helps to convert raw tags to Lua values.
Functions ¶
func PushPack ¶
func PushPack(ls *lua.LState, v *LuaPackage)
PushPack push LuaPackage object into stack.
func TableToTagset ¶
TableToTagset converts Lua-table to TagsetRaw. Lua-table keys can be number identifiers or string names associated ID values. Lua-table values can be strings, numbers, or boolean values.
func TagToValue ¶ added in v1.6.0
func ValueToTID ¶ added in v1.3.0
ValueToTID converts LValue to uint16 tag identifier. Numbers converts explicitly, strings converts to uint16 values which they presents. Error returns on any other case.
func ValueToTag ¶
ValueToTag converts LValue to TagRaw. Strings converts explicitly to byte sequence, boolen converts to 1 byte slice with 1 for 'true' and 0 for 'false'. Otherwise if it is not 'tag' uservalue with TagRaw, returns error.
Types ¶
type ErrKeyUndef ¶
type ErrKeyUndef struct {
TagKey string
}
ErrKeyUndef represents error on tag identifiers string presentation.
func (*ErrKeyUndef) Error ¶
func (e *ErrKeyUndef) Error() string
type ErrProtected ¶
type ErrProtected struct {
// contains filtered or unexported fields
}
ErrProtected is "protected tag" error.
func (*ErrProtected) Error ¶
func (e *ErrProtected) Error() string
type LuaPackage ¶
LuaPackage is "wpk" userdata structure.