fs is dir entry

This commit is contained in:
royalcat 2024-03-20 13:49:19 +03:00
parent e576e62599
commit fd3beea874
12 changed files with 172 additions and 27 deletions
src/host/vfs

View file

@ -41,6 +41,7 @@ func (d *Dummy) ReadAt(p []byte, off int64) (n int, err error) {
var _ File = &Dummy{}
type DummyFs struct {
name string
}
// Stat implements Filesystem.
@ -67,6 +68,26 @@ func (d *DummyFs) ReadDir(path string) ([]fs.DirEntry, error) {
return nil, os.ErrNotExist
}
// Info implements Filesystem.
func (d *DummyFs) Info() (fs.FileInfo, error) {
return newDirInfo(d.name), nil
}
// IsDir implements Filesystem.
func (d *DummyFs) IsDir() bool {
return true
}
// Name implements Filesystem.
func (d *DummyFs) Name() string {
return d.name
}
// Type implements Filesystem.
func (d *DummyFs) Type() fs.FileMode {
return fs.ModeDir
}
var _ Filesystem = &DummyFs{}
func TestResolver(t *testing.T) {
@ -174,7 +195,7 @@ func TestFiles(t *testing.T) {
{
file, err := getFile(files, "/test")
require.NoError(err)
require.Equal(&dir{}, file)
require.Equal(&dir{name: "test"}, file)
}
{
file, err := getFile(files, "/test/file.txt")