Bazaar resource directories support symlink (#8263)

* 🎨 bazaar resource directories support symlink

* 🎨 bazaar resource directories support symlink
This commit is contained in:
颖逸 2023-05-16 10:34:38 +08:00 committed by GitHub
parent 85496345ef
commit fdbfe6b848
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 19 deletions

View file

@ -19,6 +19,7 @@ package util
import (
"bytes"
"io"
"io/fs"
"os"
"path"
"path/filepath"
@ -42,6 +43,23 @@ func IsEmptyDir(p string) bool {
return 1 > len(files)
}
func IsDirRegularOrSymlink(dir fs.DirEntry) bool {
return dir.IsDir() || dir.Type() == fs.ModeSymlink
}
func IsPathRegularDirOrSymlinkDir(path string) bool {
fio, err := os.Stat(path)
if os.IsNotExist(err) {
return false
}
if nil != err {
return false
}
return fio.IsDir()
}
func RemoveID(name string) string {
ext := path.Ext(name)
name = strings.TrimSuffix(name, ext)