mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +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)
|
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("")
|
var _ FileSystem = LocalFileSystem("")
|
||||||
|
10
server.go
10
server.go
@ -15,12 +15,12 @@ type File interface {
|
|||||||
io.Closer
|
io.Closer
|
||||||
io.Reader
|
io.Reader
|
||||||
io.Seeker
|
io.Seeker
|
||||||
Readdir(count int) ([]os.FileInfo, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileSystem interface {
|
type FileSystem interface {
|
||||||
Open(name string) (File, error)
|
Open(name string) (File, error)
|
||||||
Stat(name string) (os.FileInfo, error)
|
Stat(name string) (os.FileInfo, error)
|
||||||
|
Readdir(name string) ([]os.FileInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
@ -109,13 +109,7 @@ func (b *backend) propfind(propfind *internal.Propfind, name string, fi os.FileI
|
|||||||
childDepth = internal.DepthZero
|
childDepth = internal.DepthZero
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := b.FileSystem.Open(name)
|
children, err := b.FileSystem.Readdir(name)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
children, err := f.Readdir(-1)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user