mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 08:14:15 +00:00
webdav: remove File.Readdir, add FileSystem.Readdir
References: https://github.com/emersion/go-webdav/issues/15
This commit is contained in:
parent
e851e6e3f1
commit
4e4a5abed2
13
fs_local.go
13
fs_local.go
@ -39,4 +39,17 @@ func (fs LocalFileSystem) Stat(name string) (os.FileInfo, error) {
|
||||
return os.Stat(p)
|
||||
}
|
||||
|
||||
func (fs LocalFileSystem) Readdir(name string) ([]os.FileInfo, error) {
|
||||
p, err := fs.path(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f, err := os.Open(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
return f.Readdir(-1)
|
||||
}
|
||||
|
||||
var _ FileSystem = LocalFileSystem("")
|
||||
|
10
server.go
10
server.go
@ -15,12 +15,12 @@ type File interface {
|
||||
io.Closer
|
||||
io.Reader
|
||||
io.Seeker
|
||||
Readdir(count int) ([]os.FileInfo, error)
|
||||
}
|
||||
|
||||
type FileSystem interface {
|
||||
Open(name string) (File, error)
|
||||
Stat(name string) (os.FileInfo, error)
|
||||
Readdir(name string) ([]os.FileInfo, error)
|
||||
}
|
||||
|
||||
type Handler struct {
|
||||
@ -109,13 +109,7 @@ func (b *backend) propfind(propfind *internal.Propfind, name string, fi os.FileI
|
||||
childDepth = internal.DepthZero
|
||||
}
|
||||
|
||||
f, err := b.FileSystem.Open(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
children, err := f.Readdir(-1)
|
||||
children, err := b.FileSystem.Readdir(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user