Added caplets windows compatibility

This commit is contained in:
realgam3 2019-09-06 17:25:54 +03:00
commit c46bb905b9
3 changed files with 25 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"sync"
@ -26,6 +27,9 @@ func List() []*Caplet {
for _, fileName := range append(files, files2...) {
if _, err := os.Stat(fileName); err == nil {
base := strings.Replace(fileName, searchPath+"/", "", -1)
if runtime.GOOS == "windows" {
base = strings.Replace(fileName, searchPath+"\\", "", -1)
}
base = strings.Replace(base, Suffix, "", -1)
if err, caplet := Load(base); err != nil {
@ -58,7 +62,7 @@ func Load(name string) (error, *Caplet) {
name += Suffix
}
if name[0] != '/' {
if !filepath.IsAbs(name) {
for _, path := range LoadPaths {
names = append(names, filepath.Join(path, name))
}