(L *LState, name, pname string)
| 28 | } |
| 29 | |
| 30 | func loFindFile(L *LState, name, pname string) (string, string) { |
| 31 | name = strings.Replace(name, ".", string(os.PathSeparator), -1) |
| 32 | lv := L.GetField(L.GetField(L.Get(EnvironIndex), "package"), pname) |
| 33 | path, ok := lv.(LString) |
| 34 | if !ok { |
| 35 | L.RaiseError("package.%s must be a string", pname) |
| 36 | } |
| 37 | messages := []string{} |
| 38 | for _, pattern := range strings.Split(string(path), ";") { |
| 39 | luapath := strings.Replace(pattern, "?", name, -1) |
| 40 | if _, err := os.Stat(luapath); err == nil { |
| 41 | return luapath, "" |
| 42 | } else { |
| 43 | messages = append(messages, err.Error()) |
| 44 | } |
| 45 | } |
| 46 | return "", strings.Join(messages, "\n\t") |
| 47 | } |
| 48 | |
| 49 | func OpenPackage(L *LState) int { |
| 50 | packagemod := L.RegisterModule(LoadLibName, loFuncs) |
no test coverage detected
searching dependent graphs…