mirror of
https://github.com/datarhei/core.git
synced 2025-10-26 01:10:30 +08:00
Fix tests
This commit is contained in:
33
io/fs/s3.go
33
io/fs/s3.go
@@ -511,6 +511,39 @@ func (fs *s3Filesystem) List(path, pattern string) []FileInfo {
|
||||
return files
|
||||
}
|
||||
|
||||
func (fs *s3Filesystem) LookPath(file string) (string, error) {
|
||||
if strings.Contains(file, "/") {
|
||||
file = fs.cleanPath(file)
|
||||
info, err := fs.Stat(file)
|
||||
if err == nil {
|
||||
if !info.Mode().IsRegular() {
|
||||
return file, os.ErrNotExist
|
||||
}
|
||||
return file, nil
|
||||
}
|
||||
return "", os.ErrNotExist
|
||||
}
|
||||
path := os.Getenv("PATH")
|
||||
for _, dir := range filepath.SplitList(path) {
|
||||
if dir == "" {
|
||||
// Unix shell semantics: path element "" means "."
|
||||
dir = "."
|
||||
}
|
||||
path := filepath.Join(dir, file)
|
||||
path = fs.cleanPath(path)
|
||||
if info, err := fs.Stat(path); err == nil {
|
||||
if !filepath.IsAbs(path) {
|
||||
return path, os.ErrNotExist
|
||||
}
|
||||
if !info.Mode().IsRegular() {
|
||||
return path, os.ErrNotExist
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
}
|
||||
return "", os.ErrNotExist
|
||||
}
|
||||
|
||||
func (fs *s3Filesystem) isDir(path string) bool {
|
||||
if !strings.HasSuffix(path, "/") {
|
||||
path = path + "/"
|
||||
|
||||
Reference in New Issue
Block a user