| 87 | } |
| 88 | |
| 89 | func searchPath(l *State, name, path, sep, dirSep string) (string, error) { |
| 90 | var msg string |
| 91 | if sep != "" { |
| 92 | name = strings.Replace(name, sep, dirSep, -1) // Replace sep by dirSep. |
| 93 | } |
| 94 | path = strings.Replace(path, string(pathListSeparator), string(filepath.ListSeparator), -1) |
| 95 | for _, template := range filepath.SplitList(path) { |
| 96 | if template != "" { |
| 97 | filename := strings.Replace(template, "?", name, -1) |
| 98 | if readable(filename) { |
| 99 | return filename, nil |
| 100 | } |
| 101 | msg = fmt.Sprintf("%s\n\tno file '%s'", msg, filename) |
| 102 | } |
| 103 | } |
| 104 | return "", errors.New(msg) |
| 105 | } |
| 106 | |
| 107 | func noEnv(l *State) bool { |
| 108 | l.Field(RegistryIndex, "LUA_NOENV") |