package vfs import ( "context" "io/fs" "os" "path" "time" ) var _ Filesystem = &DummyFs{} type DummyFs struct { name string } // ModTime implements Filesystem. func (d *DummyFs) ModTime() time.Time { return time.Time{} } // Mode implements Filesystem. func (d *DummyFs) Mode() fs.FileMode { return fs.ModeDir } // FsName implements Filesystem. func (d *DummyFs) FsName() string { return "dummyfs" } // Stat implements Filesystem. func (*DummyFs) Stat(ctx context.Context, filename string) (fs.FileInfo, error) { return NewFileInfo(path.Base(filename), 0), nil // TODO } func (d *DummyFs) Open(ctx context.Context, filename string) (File, error) { return &DummyFile{}, nil } func (d *DummyFs) Unlink(ctx context.Context, filename string) error { return ErrNotImplemented } func (d *DummyFs) ReadDir(ctx context.Context, path string) ([]fs.DirEntry, error) { if path == "/dir/here" { return []fs.DirEntry{ NewFileInfo("file1.txt", 0), NewFileInfo("file2.txt", 0), }, nil } 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 _ File = &DummyFile{} type DummyFile struct { name string } // Name implements File. func (d *DummyFile) Name() string { panic("unimplemented") } // Type implements File. func (d *DummyFile) Type() fs.FileMode { panic("unimplemented") } // Stat implements File. func (d *DummyFile) Info() (fs.FileInfo, error) { return NewFileInfo(d.name, 0), nil } func (d *DummyFile) Size() int64 { return 0 } func (d *DummyFile) IsDir() bool { return false } func (d *DummyFile) Close(ctx context.Context) error { return nil } func (d *DummyFile) Read(ctx context.Context, p []byte) (n int, err error) { return 0, nil } func (d *DummyFile) ReadAt(ctx context.Context, p []byte, off int64) (n int, err error) { return 0, nil }