github.com/fumiama/NanoBot@v0.0.0-20231122134259-c22d8183efca/lazy.go (about) 1 package nano 2 3 import ( 4 "errors" 5 "strings" 6 "unicode" 7 8 "github.com/FloatTech/floatbox/file" 9 ) 10 11 // 下载并获取本 engine 文件夹下的懒加载数据 12 func (e *Engine) GetLazyData(filename string, isDataMustEqual bool) ([]byte, error) { 13 if e.datafolder == "" { 14 return nil, errors.New("datafolder is empty") 15 } 16 if !strings.HasSuffix(e.datafolder, "/") || !strings.HasPrefix(e.datafolder, "data/") || !unicode.IsUpper(rune(e.datafolder[5])) { 17 return nil, errors.New("invalid datafolder") 18 } 19 return file.GetLazyData(e.datafolder+filename, Md5File, isDataMustEqual) 20 }