tstor/src/host/vfs/dir.go
2024-03-28 16:09:42 +03:00

59 lines
991 B
Go

package vfs
import (
"context"
"io/fs"
"path"
)
var _ File = &dirFile{}
func newDirFile(name string) File {
return &dirFile{
name: path.Base(name),
}
}
type dirFile struct {
name string
}
// Close implements File.
func (d *dirFile) Close(ctx context.Context) error {
return nil
}
// Info implements File.
func (d *dirFile) Info() (fs.FileInfo, error) {
return newDirInfo(d.name), nil
}
// IsDir implements File.
func (d *dirFile) IsDir() bool {
return true
}
// Name implements File.
func (d *dirFile) Name() string {
return d.name
}
// Read implements File.
func (d *dirFile) Read(ctx context.Context, p []byte) (n int, err error) {
return 0, fs.ErrInvalid
}
// ReadAt implements File.
func (d *dirFile) ReadAt(ctx context.Context, p []byte, off int64) (n int, err error) {
return 0, fs.ErrInvalid
}
// Size implements File.
func (d *dirFile) Size() int64 {
return 0
}
// Type implements File.
func (d *dirFile) Type() fs.FileMode {
return roMode | fs.ModeDir
}